Skip to Content
avatar image
Former Member

Interanl table output problem

Hi Friends,

I am selecting condition types(kschl) & value(kbetr) from konv table. My requirement is I need to generate output columns(alv output) based on number of or available condition type in internal table.

Internal table records:

cond.recno kschl kbetr

5890 ZBP0 1000

5890 ZBP1 1500

5890 ZFK2 500

Req. output COLUMNS :

Cond recno ZBP0 ZBP1 ZFK2

5890 1000 1500 500.

How to achieve this ?

Note: how many condtion type are available not know until run time.

Pl.Dont give any link, Provide solution to this problem. <removed_by_moderator>

Thanks in advance

senthil kumar

Edited by: Julius Bussche on Sep 4, 2008 10:38 AM

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 04, 2008 at 11:05 AM

    Hi senthil,

    I have previously done the same requirment befor you need to go for dynamic ALV reporting concept.

    Using select distinct kschl

    ................

    into internal table ( which is of single column type )

    ----


    • FORM build_dyn_itab *

    ----


    • ........ *

    ----


    FORM build_dyn_itab.

    DATA: new_table TYPE REF TO data,

    new_line TYPE REF TO data,

    wa_it_fldcat TYPE lvc_s_fcat.

    • COLUMN COUNT TO CREATE DYNAMIC INTERNAL TABLE **

    DATA: v_colpos TYPE i,

    v_colpos_new TYPE i.

    • LOADING THE DYNAMIC FIELD CATELOG TO BE PASSED **

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'VBELN'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 10.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'P_NAME1'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 35.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'KUNGR'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 10.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'FKART'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 4.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'BZIRK'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 6.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'PLTYP'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 2.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'ERNAM'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 12.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'NAME1'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 35.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'KVGRC'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 3.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'KVGRD'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 3.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'AUART'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 4.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'KWMENG'.

    wa_it_fldcat-datatype = 'QUAN'.

    wa_it_fldcat-intlen = 19.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'FKIMG'.

    wa_it_fldcat-datatype = 'QUAN'.

    wa_it_fldcat-intlen = 17.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'NONACC'.

    wa_it_fldcat-datatype = 'QUAN'.

    wa_it_fldcat-intlen = 19.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'BRGEW'.

    wa_it_fldcat-datatype = 'QUAN'.

    wa_it_fldcat-intlen = 19.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'KDGRP'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 2.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'POSNR'.

    wa_it_fldcat-datatype = 'NUMC'.

    wa_it_fldcat-intlen = 6.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'PRSDT'.

    wa_it_fldcat-datatype = 'DATS'.

    wa_it_fldcat-intlen = 10.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'MVGR2'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 3.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'ZNODNV'.

    wa_it_fldcat-datatype = 'CURR'.

    wa_it_fldcat-intlen = 18.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'SOLD'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 10.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'BILL'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 10.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'SHIP'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 10.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'SHIPADDR'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 45.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'WAERK'.

    wa_it_fldcat-datatype = 'CUKY'.

    wa_it_fldcat-intlen = 5.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'FKDAT'.

    wa_it_fldcat-datatype = 'DATS'.

    wa_it_fldcat-intlen = 10.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'AUBEL'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 10.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'ERDAT'.

    wa_it_fldcat-datatype = 'DATS'.

    wa_it_fldcat-intlen = 10.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'XBLNR'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 16.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'MATNR'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 18.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'ZTERM'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 4.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'NTGEW'.

    wa_it_fldcat-datatype = 'QUAN'.

    wa_it_fldcat-intlen = 19.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'KZWI2'.

    wa_it_fldcat-datatype = 'CURR'.

    wa_it_fldcat-intlen = 18.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'NETWR'.

    wa_it_fldcat-datatype = 'CURR'.

    wa_it_fldcat-intlen = 21.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'HZTMS'.

    wa_it_fldcat-datatype = 'CURR'.

    wa_it_fldcat-intlen = 18.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'PRODH'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 18.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'KVGR5'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 3.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'VGBEL'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 10.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'INCO1'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 3.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'LNAME1'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 35.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'BOLNR'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 35.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'WADAT'.

    wa_it_fldcat-datatype = 'DATS'.

    wa_it_fldcat-intlen = 10.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'WAVWR'.

    wa_it_fldcat-datatype = 'CURR'.

    wa_it_fldcat-intlen = 18.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'ZDIS1'.

    wa_it_fldcat-datatype = 'CURR'.

    wa_it_fldcat-intlen = 21.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'ZTMS1'.

    wa_it_fldcat-datatype = 'CURR'.

    wa_it_fldcat-intlen = 21.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'ZNOD1'.

    wa_it_fldcat-datatype = 'CURR'.

    wa_it_fldcat-intlen = 21.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'FLAGK'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 1.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos_new = v_colpos.

    • CREATE DYNAMIC FIELD COLUMNS **

    LOOP AT i_kschl.

    v_colpos_new = v_colpos_new + 1.

    wa_it_fldcat-col_pos = v_colpos_new.

    wa_it_fldcat-fieldname = i_kschl-kschl.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 4.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    CLEAR i_kschl.

    ENDLOOP.

    • METHOD USED TO OBTAIN DYNAMIC INTERNAL TABLE AS PER CATELOG **

    CALL METHOD cl_alv_table_create=>create_dynamic_table

    EXPORTING

    • I_STYLE_TABLE =

    it_fieldcatalog = it_fldcat

    IMPORTING

    ep_table = new_table

    • E_STYLE_FNAME =

    EXCEPTIONS

    generate_subpool_dir_full = 1

    OTHERS = 2.

    IF sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    ASSIGN new_table->* TO <dyn_table>.

    CREATE DATA new_line LIKE LINE OF <dyn_table>.

    ASSIGN new_line->* TO <dyn_wa>.

    ENDFORM.

    • LOADING ALL THE CONDITION TYPES TO BE DISPLAYED AS COLUMNS *

    LOOP AT int_output_1.

    READ TABLE i_kschl WITH KEY kschl = int_output_1-kschl.

    IF sy-subrc <> 0.

    i_kschl-kschl = int_output_1-kschl.

    APPEND i_kschl.

    CLEAR i_kschl.

    ENDIF.

    ENDLOOP.

    • Building the field catelog to display in the ALV grid format

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'ZTMS1'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'ZTMS Value'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'ZNOD1'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'ZNOD Value'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    ****************************************************************

    • CODED BY RAMA MURTHY **

    • ***

  • REMOVING THE DYNAMIC CONDITION RECORDS COLUMNS WITH NO CONTENT *

    • ***

    DATA: dyn_count TYPE i,

    count TYPE i.

    FIELD-SYMBOLS: <fs4>.

    DESCRIBE TABLE <dyn_table> LINES dyn_count.

    v_index_new = v_index.

    LOOP AT i_kschl .

    CLEAR count.

    LOOP AT <dyn_table> INTO <dyn_wa>.

    ASSIGN COMPONENT i_kschl-kschl OF STRUCTURE <dyn_wa> TO <fs4>.

    IF ( ( <fs4> IS INITIAL ) OR ( <fs4> EQ 0 ) ).

    count = count + 1.

    ELSE.

    CLEAR count.

    EXIT.

    ENDIF.

    ENDLOOP.

    IF count EQ dyn_count.

    CONTINUE.

    ELSE.

    • v_index_new = v_index.

    *

    • loop at i_kschl.

    v_index_new = v_index_new + 1.

    wafieldcatlog1-fieldname = i_kschl-kschl.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = i_kschl-kschl.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index_new.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    • endloop.

    ENDIF.

    endloop.

    Now pass the above field catelog and internal table of type field symbol to the FM 'REUSE_ALV_GRID_DISPLAY'.

    With best wishes,

    Murthy.

Add comment
10|10000 characters needed characters exceeded

  • Former Member Former Member

    Here is the full code.

    *----


    *

    • INCLUDE ZV_INVPR_RM

    *

    *----


    *

    *----


    *

    • Begin of Main Processing

    *----


    *

    AT SELECTION-SCREEN.

    PERFORM verify_options.

    START-OF-SELECTION.

    • YVRISA01

    ***************************************

    *----


    *

    • Begin of Main Processing

    *----


    *

    PERFORM select_sales_data. "Select sales data

    PERFORM select_likp_data. "Select delivery data

    PERFORM select_vbpa_data. "Select partner function data

    PERFORM select_bkpf_data. "Select accounting data

    PERFORM select_kna1_data. "Select customer address data

    PERFORM select_lfa1_data. "Select vendor address data

    PERFORM select_konv_data. "Select pricing data

    PERFORM select_header_data. "Select header pricing "PCR3135-718

    PERFORM join_tables. "Join tables for output

    • YVRISA01 *************************************

    • YVRPRC01 *************************************

    *----


    *

    • Begin of MAIN LOGIC

    ***********************************************

    • main report stream

    PERFORM select_process. "select records

    • YVRPRC01 *************************************

    • YVRMNR01 *************************************

    *****************************************************

    • Refresh the internal tables before any processing

    *****************************************************

    REFRESH int_vbrk_2.

    REFRESH int_output_2.

    ****************************************************************

    • Select data and fill the output table as per selection screen

    ****************************************************************

    PERFORM select-vbrk-data.

    PERFORM fill_output_table.

    • YVRMNR01 *************************************

    • YVRSMR01 *************************************

    *****************************************************

    • Refresh the internal tables before any processing

    ******************************************************

    REFRESH int_vbrk_3.

    REFRESH int_output_3.

    REFRESH int_vbkd_3.

    *****************************************************************

    • Select data and fill the output table as per selection screen

    *****************************************************************

    PERFORM select-vbrk-data_3.

    PERFORM select_vbkd_data_3.

    PERFORM fill_output_table_3.

    *****************************************************

    • Check if data was selected as per selection screen

    *****************************************************

    IF ( int_output_3[] IS INITIAL ).

    MESSAGE i031(zm). "No data for specified selection

    ENDIF.

    ***************************************************************

    • Sort the internal table (selected data per selection screen)

    ***************************************************************

    SORT int_output_3 BY zterm vbeln kunag.

    • YVRSMR01 *************************************

    • ZV_INVPR_R ***********************************

    DATA: kschl(4) TYPE c.

    SORT int_output BY vbeln posnr.

    SORT int_output_3 BY vbeln posnr.

    SORT int_output_2 BY vbeln posnr.

    SORT int_output_1 BY vbeln posnr.

    • PRM **

  • INTERNAL TABLE TABLE DECLARED TO STORE THE CONDITION TYPES *

  • CREATED ON 19-07-2007 BY RAMA MURTHY **

  • DATA:BEGIN OF i_kschl OCCURS 0,

    kschl LIKE komv-kschl,

    END OF i_kschl.

    DATA: tot_i_kschl TYPE i.

    • LOADING ALL THE CONDITION TYPES TO BE DISPLAYED AS COLUMNS *

    LOOP AT int_output_1.

    READ TABLE i_kschl WITH KEY kschl = int_output_1-kschl.

    IF sy-subrc <> 0.

    i_kschl-kschl = int_output_1-kschl.

    APPEND i_kschl.

    CLEAR i_kschl.

    ENDIF.

    ENDLOOP.

    • COUNTING THE CONDITION RECORDS SELECTED **

    • **

  • COMMENTED BY RAMA MURTHY ON 27-07-2007 *

    • **

    • describe table i_kschl lines tot_i_kschl.

    • APPLYING CONDITION TO PREVENT ALV COLUMN LIST FROM EXCEED BEYOND 90 *

    • **

  • COMMENTED BY RAMA MURTHY ON 27-07-2007 *

    • **

    • if tot_i_kschl gt 45.

    • message I167.

    • endif.

    • else.

    • GLOBAL FIELD SYMBOLS USED TO STORE DYNAMIC I_TABLE AND WA **

    FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,

    <dyn_wa>.

    DATA: it_fldcat TYPE lvc_t_fcat.

    PERFORM build_dyn_itab.

    • CODED BY MEENAKSHI ****

    • perform get_pricon_text.

    • COMMENTED BY RAMA MURTHY ON 19-07-2007 **

    • loop at int_output into wa_output.

    *

    *

    • move wa_output-sold to wa_main1-sold.

    • move wa_output-bill to wa_main1-bill.

    • move wa_output-ship to wa_main1-ship.

    • concatenate wa_output-ort01

    • wa_output-regio

    • wa_output-pstlz

    • into wa_main1-shipaddr separated by SPACE.

    • move wa_output-ort01 to wa_main1-ort01.

    • move wa_output-pstlz to wa_main1-pstlz.

    • move wa_output-regio to wa_main1-regio.

    *

    *

    • move wa_output-waerk to wa_main1-waerk.

    • move wa_output-vbeln to wa_main1-vbeln.

    • move wa_output-posnr to wa_main1-posnr.

    • move wa_output-fkdat to wa_main1-fkdat.

    • move wa_output-aubel to wa_main1-aubel.

    • move wa_output-erdat to wa_main1-erdat.

    • move wa_output-xblnr to wa_main1-xblnr.

    • move wa_output-matnr to wa_main1-matnr.

    • move wa_output-zterm to wa_main1-zterm.

    • move wa_output-ntgew to wa_main1-ntgew.

    • move wa_output-kzwi2 to wa_main1-kzwi2.

    • move wa_output-netwr to wa_main1-netwr.

    • move wa_output-hztms to wa_main1-hztms.

    • move wa_output-prodh to wa_main1-prodh.

    • move wa_output-kvgr5 to wa_main1-kvgr5.

    • move wa_output-vgbel to wa_main1-vgbel.

    • move wa_output-inco1 to wa_main1-inco1.

    • move wa_output-lname1 to wa_main1-lname1.

    • move wa_output-bolnr to wa_main1-bolnr.

    • move wa_output-wadat to wa_main1-wadat.

    • move wa_output-wavwr to wa_main1-wavwr.

    • move wa_output-zdis to wa_main1-zdis.

    • move wa_output-ztms to wa_main1-ztms.

    • move wa_output-znod to wa_main1-znod.

    *

    *

    • read table int_output_3 with key vbeln = wa_output-vbeln

    • posnr = wa_output-posnr.

    *

    *

    • move int_output_3-name1 to wa_main1-name1.

    • move int_output_3-kvgrc to wa_main1-kvgrc.

    • move int_output_3-kvgrd to wa_main1-kvgrd.

    • move int_output_3-auart to wa_main1-auart.

    • move int_output_3-kwmeng to wa_main1-kwmeng.

    • move int_output_3-fkimg to wa_main1-fkimg.

    • move int_output_3-nonacc to wa_main1-nonacc.

    • move int_output_3-brgew to wa_main1-brgew.

    *

    *

    • read table int_output_2 with key vbeln = wa_output-vbeln

    • posnr = wa_output-posnr.

    *

    • move int_output_2-kdgrp to wa_main1-kdgrp.

    • move int_output_2-posnr to wa_main1-posnr.

  • move int_output_2-prsdt to wa_main1-prsdt.

  • move int_output_2-mvgr2 to wa_main1-mvgr2.

  • move int_output_2-znodnv to wa_main1-znodnv.

  • *

    *

    • loop at int_output_1 into wa_output_1 where vbeln = wa_output-vbeln

    • and posnr = wa_output-posnr

    *.

    *

    • move wa_output_1-p_name1 to wa_main1-p_name1.

    • move wa_output_1-kunrg to wa_main1-kunrg.

    • move wa_output_1-fkart to wa_main1-fkart.

    • move wa_output_1-bzirk to wa_main1-bzirk.

    • move 'X' to wa_main1-flagk.

    • move wa_output_1-kschl to wa_main1-kschl." needs to be

    **t685t-vtext

    ************june 19th *************************

    **reading the des for con type

    *

    **read table t_condes with key kschl = wa_output_1-kschl.

    • move t_condes-vtext to wa_main1-vtext.

    • move wa_output_1-kwert to wa_main1-kwert.

  • move wa_output_1-kschl to kschl.

  • *

    • case kschl.

    • when 'VPRS'.

    • move wa_output_1-kwert to wa_main1-vprs1.

    • when 'ZANT'.

    • move wa_output_1-kwert to wa_main1-zant.

    • when 'ZCOM'.

    • move wa_output_1-kwert to wa_main1-zcom.

    • when 'ZCOS'.

    • move wa_output_1-kwert to wa_main1-zcos.

    • when 'ZDFT'.

    • move wa_output_1-kwert to wa_main1-zdft.

    • when 'ZDIS'.

    • move wa_output_1-kwert to wa_main1-zdis1.

    • when 'ZFDD'.

    • move wa_output_1-kwert to wa_main1-zfdd.

    • when 'ZINC'.

    • move wa_output_1-kwert to wa_main1-zinc.

    • when 'ZL1D'.

    • move wa_output_1-kwert to wa_main1-zl1d.

    • when 'ZL2D'.

    • move wa_output_1-kwert to wa_main1-zl2d.

    • when 'ZL3D'.

    • move wa_output_1-kwert to wa_main1-zl3d.

    • when 'ZL4D'.

    • move wa_output_1-kwert to wa_main1-zl4d.

    • when 'ZQYD'.

    • move wa_output_1-kwert to wa_main1-zqyd.

    • when 'ZRDD'.

    • move wa_output_1-kwert to wa_main1-zrdd.

    • when 'ZTMS'.

    • move wa_output_1-kwert to wa_main1-ztms1.

    • when 'ZTWC'.

    • move wa_output_1-kwert to wa_main1-ztwc.

    • when 'ZWCA'.

    • move wa_output_1-kwert to wa_main1-zwca.

    • when 'ZNOD'.

    • move wa_output_1-kwert to wa_main1-znod1.

    • when 'SKTV'.

    • move wa_output_1-kwert to wa_main1-sktv.

    • when 'ZCAL'.

    • move wa_output_1-kwert to wa_main1-zcal.

    • when 'ZBTS'.

    • move wa_output_1-kwert to wa_main1-zbts.

    • when 'ZSSC'.

    • move wa_output_1-kwert to wa_main1-zssc.

    *

    *

    *

    *

    *

    *

    • endcase.

    *

    *

    ************june 19th *************************

    • move wa_output_1-pltyp to wa_main1-pltyp.

    • move wa_output_1-ernam to wa_main1-ernam.

    *

    • append wa_main1 to t_main.

  • clear wa_output_1.

  • endloop.

  • *

    *

    *

    • append wa_main1 to t_main.

    *

    • clear wa_main1.

    • clear wa_output_1.

    • clear wa_output.

    • clear kschl.

    *

    • ENDLOOP.

    • COMMENTED BY RAMA MURTHY ON 19-07-2007 ***********************

    • SORT INT_VBRP_1 BY MATNR.

  • SORT t_main BY MATNR.

  • DELETE t_main WHERE NOT MATNR IN s_MATNR.

  • *

    • SORT INT_VBRP_1 BY KVGR5.

  • SORT t_main BY kvgr5.

  • DELETE t_main WHERE NOT KVGR5 IN s_KVGR5.

  • *

    • DELETE t_main WHERE flagk ne 'X'.

    ******************************************************************

    • POPULATING THE DYNAMIC INTERNAL TABLE **

    ******************************************************************

    FIELD-SYMBOLS: <fs2>.

    DATA: shipaddr_dup(45) TYPE c,

    flag_val TYPE c VALUE 'X'.

    DATA : v_index TYPE i,

    v_index_new TYPE i,

    v_index_cond TYPE i.

    • VARIABLE TO COUNT CONDITION VALUES PER CONDITION TYPES **

    LOOP AT int_output INTO wa_output.

    ASSIGN COMPONENT 'SOLD' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output-sold.

    ASSIGN COMPONENT 'BILL' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output-bill.

    ASSIGN COMPONENT 'SHIP' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output-ship.

    CONCATENATE wa_output-ort01

    wa_output-regio

    wa_output-pstlz

    INTO shipaddr_dup SEPARATED BY space.

    ASSIGN COMPONENT 'SHIPADDR' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = shipaddr_dup.

    ASSIGN COMPONENT 'WAERK' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output-waerk.

    ASSIGN COMPONENT 'VBELN' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output-vbeln.

    ASSIGN COMPONENT 'POSNR' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output-posnr.

    ASSIGN COMPONENT 'FKDAT' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output-fkdat.

    ASSIGN COMPONENT 'AUBEL' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output-aubel.

    ASSIGN COMPONENT 'ERDAT' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output-erdat.

    ASSIGN COMPONENT 'XBLNR' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output-xblnr.

    ASSIGN COMPONENT 'MATNR' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output-matnr.

    ASSIGN COMPONENT 'ZTERM' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output-zterm.

    ASSIGN COMPONENT 'NTGEW' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output-ntgew.

    ASSIGN COMPONENT 'KZWI2' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output-kzwi2 .

    ASSIGN COMPONENT 'NETWR' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output-netwr .

    ASSIGN COMPONENT 'HZTMS' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output-hztms .

    ASSIGN COMPONENT 'PRODH' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output-prodh .

    ASSIGN COMPONENT 'KVGR5' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output-kvgr5 .

    ASSIGN COMPONENT 'VGBEL' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output-vgbel .

    ASSIGN COMPONENT 'INCO1' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output-inco1 .

    ASSIGN COMPONENT 'LNAME1' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output-lname1 .

    ASSIGN COMPONENT 'BOLNR' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output-bolnr .

    ASSIGN COMPONENT 'WADAT' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output-wadat .

    ASSIGN COMPONENT 'WAVWR' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output-wavwr .

    ASSIGN COMPONENT 'ZDIS1' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output-zdis1.

    ASSIGN COMPONENT 'ZTMS1' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output-ztms1.

    ASSIGN COMPONENT 'ZNOD1' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output-znod1.

    READ TABLE int_output_3 WITH KEY vbeln = wa_output-vbeln

    posnr = wa_output-posnr.

    ASSIGN COMPONENT 'NAME1' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = int_output_3-name1.

    ASSIGN COMPONENT 'KVGRC' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = int_output_3-kvgrc.

    ASSIGN COMPONENT 'KVGRD' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = int_output_3-kvgrd.

    ASSIGN COMPONENT 'AUART' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = int_output_3-auart.

    ASSIGN COMPONENT 'KWMENG' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = int_output_3-kwmeng.

    ASSIGN COMPONENT 'FKIMG' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = int_output_3-fkimg.

    ASSIGN COMPONENT 'NONACC' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = int_output_3-nonacc.

    ASSIGN COMPONENT 'BRGEW' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = int_output_3-brgew.

    READ TABLE int_output_2 WITH KEY vbeln = wa_output-vbeln

    posnr = wa_output-posnr.

    ASSIGN COMPONENT 'KDGRP' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = int_output_2-kdgrp.

    ASSIGN COMPONENT 'PRSDT' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = int_output_2-prsdt.

    ASSIGN COMPONENT 'MVGR2' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = int_output_2-mvgr2.

    ASSIGN COMPONENT 'ZNODNV' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = int_output_2-znodnv.

    LOOP AT int_output_1 INTO wa_output_1 WHERE vbeln = wa_output-vbeln

    AND posnr = wa_output-posnr.

    ASSIGN COMPONENT 'P_NAME1' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output_1-p_name1.

    ASSIGN COMPONENT 'KUNGR' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output_1-kunrg.

    ASSIGN COMPONENT 'FKART' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output_1-fkart.

    ASSIGN COMPONENT 'BZIRK' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output_1-bzirk.

    ASSIGN COMPONENT 'FLAGK' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = flag_val.

    • CHANGED THE COLUMN POSITIONS OF PLTYP ERNAM FIELDS AS COMPARED TO

  • PREVIOUS STRUCTURE **

  • ASSIGN COMPONENT 'PLTYP' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output_1-pltyp.

    ASSIGN COMPONENT 'ERNAM' OF STRUCTURE <dyn_wa> TO <fs2>.

    <fs2> = wa_output_1-ernam.

    • POPULATING DYNAMIC COLUMNS **

    PERFORM build_condtyp.

    CLEAR wa_output_1.

    ENDLOOP.

    • APPENDING THE CONTENTS OF DYNAMIC WORK AREA TO DYNAMIC INTERNAL TABLE.

    APPEND <dyn_wa> TO <dyn_table>.

    CLEAR <dyn_wa>.

    CLEAR wa_output_1.

    CLEAR wa_output.

    CLEAR kschl.

    ENDLOOP.

    • APPLYING SOME REQUIRED VALIDATIONS **

    PERFORM filter_dyn_table.

    PERFORM pre_cat.

    • BUILD THE FINAL ALV LAYOUT DISPLAY **

    IF v_index_cond GT 45.

    MESSAGE i167.

    ENDIF.

    PERFORM build_alv_output.

    • endif. ** commented by VMA.

    ***********************************************************************

    • SUBROUTENES USED IN THE MAIN PROCESS ***********

    ***********************************************************************

    ----


    • FORM build_dyn_itab *

    ----


    • ........ *

    ----


    FORM build_alv_output.

    • BUILDING FIELD CATELOG FOR ALV **

    gd_repid = sy-repid.

    • ALV DISPLAY **

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER =

    • I_BUFFER_ACTIVE = ' '

    i_callback_program = gd_repid

    • I_CALLBACK_PF_STATUS_SET = ' '

    • I_CALLBACK_USER_COMMAND = ' '

    • I_STRUCTURE_NAME =

    • IS_LAYOUT =

    it_fieldcat = it_fieldcatalog1[]

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_DEFAULT = 'X'

    i_save = 'A'

    • IS_VARIANT =

    • IT_EVENTS = i_events

    • IT_EVENT_EXIT =

    is_print = gd_prntparams

    • IS_REPREP_ID =

    • I_SCREEN_START_COLUMN = 0

    • I_SCREEN_START_LINE = 0

    • I_SCREEN_END_COLUMN = 0

    • I_SCREEN_END_LINE = 0

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

    TABLES

    t_outtab = <dyn_table>

    • EXCEPTIONS

    • PROGRAM_ERROR = 1

    • OTHERS = 2

    .

    IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

    ENDFORM.

    • FORM TO POPULATE THE ROWS CORRESPONDING TO THE COLUMS OF CONDITION

  • TYPES **

  • FORM build_condtyp.

    FIELD-SYMBOLS: <fs1>.

    LOOP AT i_kschl WHERE kschl = wa_output_1-kschl.

    ASSIGN COMPONENT i_kschl-kschl OF STRUCTURE <dyn_wa> TO <fs1>.

    <fs1> = wa_output_1-kwert.

    ENDLOOP.

    ENDFORM.

    *&----


    *

    *& Form verify_options

    *&----


    *

    FORM verify_options.

    SELECT SINGLE stunr

    FROM t683t INTO wk_zusaam_stunr

    WHERE kalsm = 'ZUSAAM'

    AND vtext = 'Net Value for Item'.

    IF sy-subrc <> 0.

    MESSAGE e999(fr)." WITH text-074.

    wk_zusaam_exist = 'N'.

    ENDIF.

    SELECT SINGLE stunr

    FROM t683t INTO wk_zcanam_stunr

    WHERE kalsm = 'ZCANAM'

    AND vtext = 'Net Value for Item'.

    IF sy-subrc <> 0.

    MESSAGE e999(fr)." WITH text-075.

    wk_zcanam_exist = 'N'.

    ENDIF.

    *check org in Master

    IF NOT s_vkorg-low IS INITIAL. "PCR 3135-599

    SELECT SINGLE * FROM tvko

    WHERE vkorg IN s_vkorg.

    IF sy-subrc <> 0.

    MESSAGE e021.

    ENDIF.

    ENDIF. "PCR 3135-599

    *check sold-to party in Master

    IF NOT s_kunag-low IS INITIAL. "PCR 3135-599

    SELECT SINGLE * FROM kna1

    WHERE kunnr IN s_kunag.

    IF sy-subrc <> 0.

    MESSAGE e024.

    ENDIF.

    ENDIF. "PCR 3135-599

    *check price list type in Master

    IF NOT s_pltyp-low IS INITIAL. "PCR 3135-599

    SELECT SINGLE * FROM t189

    WHERE pltyp IN s_pltyp.

    IF sy-subrc <> 0.

    MESSAGE e097.

    ENDIF.

    ENDIF. "PCR 3135-599

    *Check Customer Group in Master

    IF NOT s_kdgrp-low IS INITIAL. "PCR 3135-599

    SELECT SINGLE * FROM t151

    WHERE kdgrp IN s_kdgrp.

    IF sy-subrc <> 0.

    MESSAGE e038.

    ENDIF.

    ENDIF. "PCR 3135-599

    *Check Trade Class in Master

    IF NOT s_kvgr5-low IS INITIAL. "PCR 3135-599

    SELECT SINGLE * FROM tvv5

    WHERE kvgr5 IN s_kvgr5.

    IF sy-subrc <> 0.

    MESSAGE e025.

    ENDIF.

    ENDIF. "PCR 3135-599

    *check billing type in Master

    IF NOT s_fkart-low IS INITIAL. "PCR 3135-599

    SELECT SINGLE * FROM tvfk

    WHERE fkart IN s_fkart.

    IF sy-subrc <> 0.

    MESSAGE e073.

    ENDIF.

    ENDIF. "PCR 3135-599

    *check sales document type in Master

    IF NOT s_auart-low IS INITIAL. "PCR 3135-599

    SELECT SINGLE * FROM tvak

    WHERE auart IN s_auart.

    IF sy-subrc <> 0.

    MESSAGE e082.

    ENDIF.

    ENDIF. "PCR 3135-599

    ENDFORM.

    • AT SELECTION SCREEN FORMS

    *************************

    • YVRISA01 - FORMS

    *******************************

    *----


    *

    • Form SELECT_SALES_DATA

    *----


    *

    • Select sales data from vbrk, vbrp, vbak, and vbap

    *----


    *

    FORM select_sales_data.

    SELECT vbrk~vbeln "Billing Doc

    vbrk~fkart "Billing type

    vbrk~waerk "Currency

    vbrk~knumv "Number of the document condition

    vbrk~fkdat "Billing Date

    vbrk~inco1 "Terms of Delivery

    vbrk~zterm "Payment Terms

    vbrk~bukrs "Company Code

    vbrk~kunag "Sold-to party

    vbrk~xblnr "PO Reference No

    vbrp~posnr "Billing Doc Item

    vbrp~fkimg "Quantity

    vbrp~ntgew "Net Weight

    vbrp~netwr "Net Value

    vbrp~vgbel "Delivery No

    vbrp~vgpos "Delivery Item

    vbrp~aubel "Sales Doc

    vbrp~aupos "Sales Doc Item

    vbrp~matnr "Material

    vbrp~prodh "Product Hierarchy

    vbrp~wavwr "Cost

    vbrp~kzwi2 "Subtotal 2

    vbrp~kvgr5 "Trade Class

    vbak~erdat "Sales Doc Creation Date

    vbak~knumv "Condition no for SD "PCR3135-718

    vbap~posnr "Sales Doc Item

    INTO TABLE int_vbrk

    FROM vbrk

    INNER JOIN vbrp ON vbrkvbeln = vbrpvbeln

    INNER JOIN vbap ON vbrpaubel = vbapvbeln

    AND vbrpaupos = vbapposnr

    INNER JOIN vbak ON vbapvbeln = vbakvbeln

    WHERE vbrk~vkorg IN s_vkorg

    AND vbrk~vbeln IN s_vbeln

    AND vbrk~kunag IN s_kunag

    AND vbrk~pltyp IN s_pltyp

    AND vbrk~kdgrp IN s_kdgrp

    AND vbrk~fkart IN s_fkart

    AND vbrk~fkdat IN s_fkdat

    AND vbrp~kvgr5 IN s_kvgr5

    AND vbrp~mvgr2 IN s_mvgr2

    AND vbrp~mvgr1 IN s_mvgr1 " added for ZV_INVPR_R

    AND vbrp~mvgr3 IN s_mvgr3 " added for ZV_INVPR_R

    AND vbrp~mvgr4 IN s_mvgr4 " added for ZV_INVPR_R

    AND vbrp~mvgr5 IN s_mvgr5

    AND vbak~auart IN s_auart

    • AND ( vbrkkalsm = 'ZUSAAM' OR vbrkkalsm = 'ZCANAM' )"

    *added

    • " for ZV_INVPR_R

    • commented on 16-Jul-07

    AND vbrk~erdat IN s_erdat " added for ZV_INVPR_R

    AND vbrk~waerk IN s_waerk " added for ZV_INVPR_R

    AND vbrp~matnr IN s_matnr " added for ZV_INVPR_R

    AND vbrk~kunrg IN s_kunrg " added for ZV_INVPR_R

    AND vbrk~bzirk IN s_bzirk " added for ZV_INVPR_R

    AND vbak~ernam IN s_ernam." added for ZV_INVPR_R

    IF int_vbrk[] IS INITIAL.

    MESSAGE i999(fr) WITH text-010.

    STOP.

    ELSE.

    SORT int_vbrk BY vbeln posnr.

    ENDIF.

    ENDFORM. " SELECT_SALES_DATA

    *----


    *

    • Form SELECT_LIKP_DATA

    *----


    *

    • Select likp data

    *----


    *

    FORM select_likp_data.

    int_delv[] = int_vbrk[].

    SORT int_delv[] BY vgbel.

    DELETE ADJACENT DUPLICATES FROM int_delv COMPARING vgbel.

    IF NOT int_delv[] IS INITIAL.

    SELECT likp~vbeln "Delivery number

    bolnr "Bill of Lading

    wadat_ist "Ship Date

    posnr

    INTO TABLE int_likp

    FROM likp

    INNER JOIN lips ON likpvbeln = lipsvbeln

    FOR ALL entries IN int_delv

    WHERE likp~vbeln = int_delv-vgbel.

    ENDIF.

    IF NOT int_likp[] IS INITIAL. "3141-218

    SORT int_likp BY vbeln posnr.

    ENDIF. "3141-218

    FREE int_delv. "3141-218

    ENDFORM. " SELECT_LIKP_DATA

    *----


    *

    • Form SELECT_BKPF_DATA

    *----


    *

    • Select accounting data

    *----


    *

    FORM select_bkpf_data.

    • Create fiscal year range

    *if s_fkdat-high is initial.

    • move s_fkdat-low+0(4) to ra_gjahr-low.

    • if s_fkdat-low+2(2) = '12'.

    • wf_year = ra_gjahr-low + 1.

    • move wf_year to ra_gjahr-high.

    • move 'BT' to ra_gjahr-option.

    • move 'I' to ra_gjahr-sign.

    • append ra_gjahr.

    • else.

    • move 'EQ' to ra_gjahr-option.

    • move 'I' to ra_gjahr-sign.

    • append ra_gjahr.

    • endif.

    *else.

    • move s_fkdat-low+0(4) to ra_gjahr-low.

    • if s_fkdat-high+2(2) = '12'.

    • wf_year = ra_gjahr-low + 1.

    • move wf_year to ra_gjahr-high.

    • move 'BT' to ra_gjahr-option.

    • move 'I' to ra_gjahr-sign.

    • append ra_gjahr.

    • else.

    • move 'EQ' to ra_gjahr-option.

    • move 'I' to ra_gjahr-sign.

    • append ra_gjahr.

    • endif.

    *endif.

    • Select accouting document data

    IF NOT int_cust[] IS INITIAL.

    IF NOT s_monat IS INITIAL.

    IF NOT s_gjahr IS INITIAL.

    SELECT bukrs "Company code

    belnr "Accounting doc

    gjahr "Fiscal year

    awkey "Object key

    FROM bkpf

    INTO TABLE int_bkpf

    FOR ALL ENTRIES IN int_cust

    WHERE bukrs = int_cust-bukrs

    AND belnr BETWEEN '0005000000' AND '0005999999'

    AND gjahr IN s_gjahr

    AND monat IN s_monat.

    ENDIF.

    ENDIF.

    ENDIF.

    IF NOT int_bkpf[] IS INITIAL. "3141-218

    SORT int_bkpf BY bukrs awkey.

    ENDIF. "3141-218

    FREE int_cust. "3141-218

    ENDFORM. " SELECT_BKPF_DATA

    *----


    *

    • Form SELECT_VBFA_DATA

    *----


    *

    • Select partner function data from vbpa

    *----


    *

    FORM select_vbpa_data.

    int_cust[] = int_vbrk[].

    SORT int_cust BY vbeln.

    DELETE ADJACENT DUPLICATES FROM int_cust COMPARING vbeln.

    IF NOT int_cust[] IS INITIAL.

    SELECT vbeln "SD Document number

    parvw "Partner function

    kunnr "Customer number

    lifnr "Account number of vendor

    FROM vbpa

    INTO TABLE int_vbpa

    FOR ALL ENTRIES IN int_cust

    WHERE vbeln = int_cust-vbeln

    AND posnr BETWEEN '000000' AND '999999'.

    ENDIF.

    IF NOT int_vbpa[] IS INITIAL. "3141-218

    SORT int_vbpa BY vbeln parvw.

    ENDIF. "3141-218

    ENDFORM. " SELECT_VBPA_DATA

    *----


    *

    • Form SELECT_KNA1_DATA

    *----


    *

    • Select address data

    *----


    *

    FORM select_kna1_data.

    int_custven[] = int_vbpa[]. "3141-218

    SORT int_custven BY kunnr. "3141-218

    DELETE ADJACENT DUPLICATES

    FROM int_custven COMPARING kunnr. "3141-218

    IF NOT int_custven[] IS INITIAL. "3141-218

    SELECT kunnr "Customer

    name1 "Name

    ort01 "City

    pstlz "Postal Code

    regio "Region

    FROM kna1

    INTO TABLE int_kna1

    FOR ALL ENTRIES IN int_custven "3141-218

    WHERE kunnr = int_custven-kunnr. "3141-218

    ENDIF. "3141-218

    IF NOT int_kna1[] IS INITIAL. "3141-218

    SORT int_kna1.

    ENDIF. "3141-218

    FREE int_custven. "3141-218

    ENDFORM. " SELECT_KNA1_DATA

    *----


    *

    • Form SELECT_LFA1_DATA

    *----


    *

    • Select vendor address data

    *----


    *

    FORM select_lfa1_data.

    int_custven[] = int_vbpa[]. "3141-218

    SORT int_custven BY lifnr. "3141-218

    DELETE ADJACENT DUPLICATES

    FROM int_custven COMPARING lifnr. "3141-218

    IF NOT int_custven[] IS INITIAL. "3141-218

    SELECT lifnr "Vendor

    name1 "Name

    FROM lfa1

    INTO TABLE int_lfa1

    FOR ALL ENTRIES IN int_custven "3141-218

    WHERE lifnr = int_custven-lifnr. "3141-218

    ENDIF. "3141-218

    IF NOT int_lfa1[] IS INITIAL. "3141-218

    SORT int_lfa1.

    ENDIF. "3141-218

    FREE int_custven. "3141-218

    ENDFORM. " SELECT_LFA1_DATA

    *----


    *

    • Form SELECT_KONV_DATA

    *----


    *

    • Select data from konv

    *----


    *

    FORM select_konv_data.

    int_price[] = int_vbrk[].

    IF NOT int_price[] IS INITIAL. "3141-218

    SORT int_price BY vbeln posnr. "3141-218

    DELETE ADJACENT DUPLICATES FROM int_price

    COMPARING vbeln posnr. "3141-218

    ENDIF. "3141-218

    IF NOT int_price[] IS INITIAL.

    SELECT knumv "Number of the document condition

    kposn "Condition item number

    kschl "Condition type

    krech "Calculation type for condition

    kawrt "Condition base value

    kbetr "Rate (condition amount orpercentag

    kpein "Condition pricing unit

    FROM konv

    INTO TABLE int_konv

    FOR ALL ENTRIES IN int_price

    WHERE knumv = int_price-knumv

    AND kposn = int_price-posnr

    AND ( kschl = 'ZNOD'

    OR kschl = 'ZTMS'

    OR kschl = 'ZDIS'

    OR kschl = 'VPRS' ).

    SORT int_konv BY knumv kposn kschl. "3141-218

    • delete int_konv where not kschl in s_kschl. " added for zv_invpr_r

    *&*

    *loop at int_konv.

    • if not int_konv-kschl in s_kschl.

    • int_konv-flagk = 'X'.

    • modify int_konv.

    • endif.

    *

    *endloop.

    *

    ENDIF.

    *sort int_konv by knumv kposn kschl. "3141-218

    FREE int_price.

    ENDFORM. " SELECT_KONV_DATA

    *----


    *

    • Form SELECT_HEADER_DATA

    *----


    *

    • Select header pricing data. Select all ZTMS values from

    • the sales document.

    *----


    *

    FORM select_header_data.

    int_price[] = int_vbrk[].

    IF NOT int_price[] IS INITIAL.

    SORT int_price BY knumv1. "3141-218

    DELETE ADJACENT DUPLICATES FROM int_price

    COMPARING knumv. "3141-218

    ENDIF. "3141-218

    IF NOT int_price[] IS INITIAL. "3141-218

    SELECT knumv "Number of the document condition

    kschl "Condition type

    krech "Calculation type for condition

    kawrt "Condition base value

    kbetr "Rate (condition amount or percentage

    kpein "Condition pricing unit

    kwert "Condition vaue

    FROM konv

    INTO TABLE int_konv1

    FOR ALL ENTRIES IN int_price

    WHERE knumv = int_price-knumv1

    AND kschl = 'ZTMS'.

    ENDIF.

    FREE int_price. "3141-218

    IF NOT int_konv1[] IS INITIAL. "3141-218

    SORT int_konv1 BY knumv.

    • Sum ZTMS values for all items in each SD doc, ie. by Condition No.

    LOOP AT int_konv1.

    MOVE: int_konv1-kwert TO int_konv2-wavwr,

    int_konv1-knumv TO int_konv2-knumv.

    COLLECT int_konv2.

    ENDLOOP.

    ENDIF. "3141-218

    FREE int_konv1. "3141-218

    SORT int_konv2.

    ENDFORM. " SELECT_HEADER_DATA

    *----


    *

    • Form COL_HEADERS

    *----


    *

    • Write column headings

    *----


    *

    *FORM col_headers.

    • 1st line

  • FORMAT COLOR 1 ON INTENSIFIED ON.

  • WRITE: / text-006,

  • 130 text-007.

  • ULINE.

  • *

    • 2nd line

  • FORMAT COLOR 2 ON INTENSIFIED ON.

  • WRITE: / text-008,

  • 129 text-009.

  • *

    • ULINE.

    • FORMAT RESET.

    *

    *ENDFORM. " COL_HEADERS

    *----


    *

    • Form JOIN_TABLES

    *----


    *

    • Join tables for output

    *----


    *

    FORM join_tables.

    SORT int_vbrk BY vgbel vgpos. "3141-218

    LOOP AT int_vbrk.

    • Check if billing document is in fiscal year/period

    IF NOT s_gjahr IS INITIAL.

    IF NOT s_monat IS INITIAL.

    READ TABLE int_bkpf WITH KEY bukrs = int_vbrk-bukrs

    awkey = int_vbrk-vbeln

    BINARY SEARCH.

    IF sy-subrc <> 0.

    CONTINUE.

    ENDIF.

    ENDIF.

    ENDIF.

    MOVE: int_vbrk-kunag TO int_output-sold, "Sold to party

    int_vbrk-vbeln TO int_output-vbeln, "Billing doc no

    *******Added for ZV_INVPR_R

    int_vbrk-posnr TO int_output-posnr, "ITEM

    ***************************

    int_vbrk-fkdat TO int_output-fkdat, "Billing doc date

    int_vbrk-aubel TO int_output-aubel, "Sales doc no

    int_vbrk-erdat TO int_output-erdat, "Sales doc date

    int_vbrk-xblnr TO int_output-xblnr, "PO number

    int_vbrk-matnr TO int_output-matnr, "Material

    int_vbrk-fkimg TO int_output-fkimg, "Quantity

    int_vbrk-ntgew TO int_output-ntgew, "Net weight

    int_vbrk-prodh TO int_output-prodh, "Product hierarchy

    int_vbrk-kvgr5 TO int_output-kvgr5, "Trade class

    int_vbrk-fkart TO int_output-fkart, "Billing type

    int_vbrk-vgbel TO int_output-vgbel, "Delivery no

    int_vbrk-zterm TO int_output-zterm, "Payment terms

    int_vbrk-kzwi2 TO int_output-kzwi2, "Net value beforeadj

    int_vbrk-netwr TO int_output-netwr, "Net value after adj

    int_vbrk-inco1 TO int_output-inco1, "Incoterms

    int_vbrk-waerk TO int_output-waerk. "Currency

    • Move delivery data

    READ TABLE int_likp WITH KEY vbeln = int_vbrk-vgbel

    BINARY SEARCH.

    IF sy-subrc = 0.

    MOVE: int_likp-bolnr TO int_output-bolnr, "BOL

    int_likp-wadat_ist TO int_output-wadat. "Ship Date

    ENDIF.

    *&*

    *

    *read table int_konv with key knumv = int_vbrk-knumv

    • kposn = int_vbrk-posnr

    • kschl in s_kschl.

    • if sy-subrc <> 0.

    • move 'X' to int_output-flagk.

    • endif.

    • Move VPRS value (Cost)

    READ TABLE int_konv WITH KEY knumv = int_vbrk-knumv

    kposn = int_vbrk-posnr

    kschl = 'VPRS'

    BINARY SEARCH.

    IF sy-subrc = 0.

    IF int_konv-krech <> 'C'.

    MOVE int_konv-kawrt TO int_output-wavwr.

    ELSE.

    int_output-wavwr = int_konv-kbetr / int_konv-kpein.

    ENDIF.

    ENDIF.

    • Move ZNOD value

    READ TABLE int_konv WITH KEY knumv = int_vbrk-knumv

    kposn = int_vbrk-posnr

    kschl = 'ZNOD'

    BINARY SEARCH.

    IF sy-subrc = 0.

    IF int_konv-krech <> 'C'.

    MOVE int_konv-kawrt TO int_output-znod1.

    ELSE.

    MOVE int_konv-kbetr TO int_output-znod1.

    ENDIF.

    ENDIF.

    • Move ZTMS value

    READ TABLE int_konv WITH KEY knumv = int_vbrk-knumv

    kposn = int_vbrk-posnr

    kschl = 'ZTMS'

    BINARY SEARCH.

    IF sy-subrc = 0.

    IF int_konv-krech <> 'C'.

    MOVE int_konv-kawrt TO int_output-ztms1.

    ELSE.

    MOVE int_konv-kbetr TO int_output-ztms1.

    ENDIF.

    ENDIF.

    • Move ZDIS value

    READ TABLE int_konv WITH KEY knumv = int_vbrk-knumv

    kposn = int_vbrk-posnr

    kschl = 'ZDIS'

    BINARY SEARCH.

    IF sy-subrc = 0.

    IF int_konv-krech <> 'C'.

    MOVE int_konv-kawrt TO int_output-zdis1.

    ELSE.

    MOVE int_konv-kbetr TO int_output-zdis1.

    ENDIF.

    ENDIF.

    • Move Bill-to party

    READ TABLE int_vbpa WITH KEY vbeln = int_vbrk-vbeln

    parvw = 'RE'

    BINARY SEARCH.

    IF sy-subrc = 0.

    MOVE int_vbpa-kunnr TO int_output-bill.

    ENDIF.

    • Move Ship-to party

    CLEAR int_vbpa.

    READ TABLE int_vbpa WITH KEY vbeln = int_vbrk-vbeln

    parvw = 'WE'

    BINARY SEARCH.

    IF sy-subrc = 0.

    MOVE int_vbpa-kunnr TO int_output-ship.

    ENDIF.

    • Move ship-to address

    READ TABLE int_kna1 WITH KEY kunnr = int_vbpa-kunnr

    BINARY SEARCH.

    IF sy-subrc = 0.

    MOVE: int_kna1-ort01 TO int_output-ort01,

    int_kna1-regio TO int_output-regio,

    int_kna1-pstlz TO int_output-pstlz.

    ENDIF.

    • Determine Forwarding Agent

    CLEAR int_vbpa.

    READ TABLE int_vbpa WITH KEY vbeln = int_vbrk-vbeln

    parvw = 'SP'

    BINARY SEARCH.

    • Move Forwarding Agent name

    IF sy-subrc = 0.

    READ TABLE int_lfa1 WITH KEY lifnr = int_vbpa-lifnr

    BINARY SEARCH.

    IF sy-subrc = 0.

    MOVE int_lfa1-lname1 TO int_output-lname1.

    ENDIF.

    ENDIF.

    • NKA7077 PCR 3135-718 11/05/03 Begin

    • Move the ZTMS price from the header level

    CLEAR int_konv2.

    READ TABLE int_konv2 WITH KEY knumv = int_vbrk-knumv1

    BINARY SEARCH.

    IF sy-subrc = 0.

    MOVE int_konv2-wavwr TO int_output-hztms.

    ENDIF.

    • NKA7077 PCR 3135-718 End

    • 3141-218 09/21/2004 RAH3941 removes identical select

    • by including function call within on change of delivery

  • ON CHANGE OF int_vbrk-vgbel. "3141-218

    • pgw5948 start "PCR 3135-895

  • CLEAR: int_lines.

  • REFRESH: int_lines.

  • MOVE int_vbrk-vgbel TO wf_name_key.

  • CALL FUNCTION 'READ_TEXT'

  • EXPORTING

  • id = 'Z003'

  • language = sy-langu

  • name = wf_name_key

  • object = 'VBBK'

  • TABLES

  • lines = int_lines

  • EXCEPTIONS

  • id = 1

  • language = 2

  • name = 3

  • not_found = 4

  • object = 5

  • reference_check = 6

  • wrong_access_to_archive = 7

  • OTHERS = 8.

  • *

    • DESCRIBE TABLE int_lines LINES sy-tfill.

    • IF sy-tfill <> 0.

    • READ TABLE int_lines INDEX 1.

    • MOVE int_lines-tdline TO int_output-protext.

    • ENDIF.

    • PGW5948 END "PCR 3135-895

  • ENDON. "3141-218

  • *

    APPEND int_output.

    CLEAR int_output.

    ENDLOOP.

    *delete int_output where flagk = 'X'.

    • BOC RAH3941 09/21/2004 Free memory "3141-218

    FREE: int_vbrk,

    int_konv,

    int_konv2,

    int_likp,

    int_kna1,

    int_vbpa,

    int_lfa1.

    • EOC RAH3941 09/21/2004 Free memory "3141-218

    ENDFORM. " JOIN_TABLES

    • YVRISA01 - FORMS

    *******************************

    • YVRPRC01 - FORMS

    *******************************

    *&----


    *

    *& Form SELECT_PROCESS

    *&----


    *

    • This form selects the records for processing, building the internal

    *

    • tables for print output. Loop through detail recs getting header

    *

    • information for each new document and the customer name. For each

    *

    • new document gets complete pricing information and stores in table.

    *

    • Each output record is populated with header,detail info, and pricing

    *

    • type for each item detail record. These are summed by header info

    *

    • and vbeln so that each pricing type generates a different output

    *

    • record for the document.

    *

    *----


    *

    FORM select_process.

    • Select billing info from sales index table.

    SELECT vbeln

    FROM vrkpa

    INTO TABLE int_vrkpa_1

    WHERE vkorg IN s_vkorg

    AND fkart IN s_fkart

    AND kunnr IN s_kunrg

    AND kunag IN s_kunag

    AND fkdat IN s_fkdat.

    SORT int_vrkpa_1.

    IF NOT int_vrkpa_1[] IS INITIAL.

    • EXCLUDE CANCELS

    SELECT vbeln kunag kunrg fkdat fkart pltyp

    waerk bukrs ernam vkorg bzirk knumv

    FROM vbrk

    INTO TABLE int_vbrk_1

    FOR ALL ENTRIES IN int_vrkpa_1

    WHERE vbeln = int_vrkpa_1-vbeln

    AND pltyp IN s_pltyp

    AND fksto NE 'X'

    AND bzirk IN s_bzirk.

    SORT int_vbrk_1.

    IF NOT int_vbrk_1[] IS INITIAL.

    DESCRIBE TABLE int_vbrk_1 LINES w_lines.

    DO w_lines TIMES.

    READ TABLE int_vbrk_1 INTO wa_vbrk_1 INDEX sy-index.

    SELECT f~vbeln f~posnr f~matnr f~fklmg

    f~netwr q~ernam f~kondm f~aubel f~kvgr5

    INTO CORRESPONDING FIELDS OF wa_vbrp_1

    FROM vbrp AS f

    INNER JOIN vbak AS q ON

    f~aubel = q~vbeln

    WHERE f~vbeln = wa_vbrk_1-vbeln AND

    q~ernam IN s_ernam .

    IF sy-subrc = 0.

    APPEND wa_vbrp_1 TO int_vbrp_1.

    ENDIF.

    ENDSELECT.

    ENDDO.

    SORT int_vbrp_1 BY matnr.

    • DELETE INT_VBRP_1 WHERE NOT MATNR IN s_MATNR.

    SORT int_vbrp_1 BY kvgr5.

    • DELETE INT_VBRP_1 WHERE NOT KVGR5 IN s_KVGR5.

    SORT int_vbrp_1.

    ELSE.

    MESSAGE e001(zf) WITH 'No records selected for processing'.

    ENDIF.

    ELSE.

    MESSAGE e001(zf) WITH 'No records selected for processing'.

    ENDIF.

    LOOP AT int_vbrp_1 INTO wa_vbrp_1.

    SELECT SINGLE * FROM makt

    WHERE matnr = wa_vbrp_1-matnr.

    IF sy-subrc <> 0.

    makt-maktx = ' '.

    ENDIF.

    AT NEW vbeln.

    • Get additional billing document header information

    READ TABLE int_vbrk_1 INTO wa_vbrk_1

    WITH KEY vbeln = wa_vbrp_1-vbeln.

    IF sy-subrc NE 0.

    MESSAGE e041(vf) WITH wa_vbrp_1-vbeln.

    ENDIF.

    • get payer name

    SELECT SINGLE * FROM kna1

    WHERE kunnr = wa_vbrk_1-kunrg.

    wa_name1 = kna1-name1.

    • Get sold to customer name

    SELECT SINGLE * FROM kna1

    WHERE kunnr = wa_vbrk_1-kunag.

    • Get pricing

    REFRESH int_konv_1.

    • SELECT KPOSN KSCHL FROM KONV "NKA7077 P04-0066 - 243

    SELECT kposn kschl kwert FROM konv "NKA7077 P04-0066 - 243

    INTO TABLE int_konv_1

    WHERE knumv = wa_vbrk_1-knumv.

    SORT int_konv_1 BY kschl.

    DELETE int_konv_1 WHERE NOT kschl IN s_kschl.

    SORT int_konv_1 BY kposn kschl.

    ENDAT. . "end of new document no.

    CHECK: NOT int_konv_1[] IS INITIAL.

    SELECT SINGLE * FROM vbkd

    WHERE vbeln = wa_vbrp_1-aubel

    AND posnr = '000000'.

    IF sy-subrc = 0.

    CHECK: vbkd-bstkd IN s_bstkd.

    ENDIF.

    LOOP AT int_konv_1 INTO wa_konv_1

    WHERE kposn = wa_vbrp_1-posnr.

    • Prepare output file for report.

    PERFORM prepare_output.

    ENDLOOP.

    ENDLOOP. " end of details

    ENDFORM. " SELECT_PROCESS

    *&----


    *

    *& Form PREPARE_OUTPUT

    *&----


    *

    • This form moves the intended output data to an output table.

    *----


    *

    FORM prepare_output.

    CLEAR wa_output_1.

    MOVE: kna1-name1 TO wa_output_1-name1,

    kna1-ort01 TO wa_output_1-ort01,

    kna1-regio TO wa_output_1-regio,

    wa_name1 TO wa_output_1-p_name1,

    vbkd-bstkd TO wa_output_1-bstkd,

    wa_vbrk_1-kunag TO wa_output_1-kunag,

    wa_vbrk_1-kunrg TO wa_output_1-kunrg,

    wa_vbrk_1-fkdat TO wa_output_1-fkdat,

    wa_vbrk_1-fkart TO wa_output_1-fkart,

    wa_vbrp_1-vbeln TO wa_output_1-vbeln,

    *********Added to ZV_INVR_R

    wa_vbrp_1-posnr TO wa_output_1-posnr,

    ***************************

    wa_konv_1-kschl TO wa_output_1-kschl,

    wa_konv_1-kwert TO wa_output_1-kwert,"NKA7077 P04-0066-243

    wa_vbrk_1-pltyp TO wa_output_1-pltyp,

    wa_vbrp_1-matnr TO wa_output_1-matnr,

    makt-maktx TO wa_output_1-maktx,

    wa_vbrp_1-fklmg TO wa_output_1-fklmg,

    wa_vbrp_1-netwr TO wa_output_1-netwr,

    wa_vbrk_1-waerk TO wa_output_1-waerk,

    wa_vbrk_1-bukrs TO wa_output_1-bukrs,

    wa_vbrp_1-ernam TO wa_output_1-ernam,

    wa_vbrk_1-vkorg TO wa_output_1-vkorg,

    wa_vbrp_1-kvgr5 TO wa_output_1-kvgr5,

    wa_vbrk_1-bzirk TO wa_output_1-bzirk.

    *

    • COLLECT WA_OUTPUT_1 INTO INT_OUTPUT_1.

    APPEND wa_output_1 TO int_output_1.

    DELETE int_output_1 WHERE NOT kschl IN s_kschl. "AddeddforZV_INVPR_R

    ENDFORM. " PREPARE_OUTPUT

    • YVRPRC01 - FORMS

    *******************************

    • YVRMNR01- FORMS

    ********************************

    *&----


    *

    *& Form SELECT-VBRK-DATA VBRP and VBAK

    *&----


    *

    *----


    *

    *----


    *

    FORM select-vbrk-data.

    SELECT f~vbeln

    f~fkdat

    • F~GJAHR "PCR 3135-599

    f~kunag

    f~bstnk_vf

    f~knumv

    f~kalsm

    f~waerk

    f~pltyp

    f~kdgrp

    f~bukrs "PCR 3135-599

    f~logsys "PCR 3135-599

    pposnr pmatnr pfkimg paubel paupos pprodh p~kzwi2

    p~netwr

    p~prsdt "NKA7077 PCR 3135-842

    p~wavwr "NKA7077 PCR 3135-020

    p~kvgr5

    q~erdat "NKA7077 PCR 3135-127

    q~auart

    r~mvgr2 "SBB8868 PCR# 3484-001

    • INTO CORRESPONDING FIELDS OF INT_VBRK "NKA7077 PCR 3135-842

    INTO TABLE int_vbrk_2 "NKA7077 PCR 3135-842

    FROM vbrk AS f

    INNER JOIN vbrp AS p ON

    fvbeln = pvbeln

    INNER JOIN vbak AS q ON

    paubel = qvbeln

    LEFT JOIN vbap AS r ON "SBB8868 PCR# 3484-001

    paubel = rvbeln AND "SBB8868 PCR# 3484-001

    paupos = rposnr "SBB8868 PCR# 3484-001

    WHERE f~fkart IN s_fkart

    AND f~vkorg IN s_vkorg

    AND f~fkdat IN s_fkdat

    AND f~kunag IN s_kunag

    AND f~pltyp IN s_pltyp

    AND f~kdgrp IN s_kdgrp

    AND p~kvgr5 IN s_kvgr5

    AND p~mvgr5 IN s_mvgr5 "NKA7077 PCR# 3135-558

    AND p~mvgr2 IN s_mvgr2 "NKA7077 PCR 3135-842

    AND p~mvgr1 IN s_mvgr1

    AND p~mvgr3 IN s_mvgr3

    AND p~mvgr4 IN s_mvgr4

    AND q~auart IN s_auart

    • AND ( FKALSM = 'ZUSAAM' OR FKALSM = 'ZCANAM' ) "

    *commented on 16-Jul-07

    AND f~waerk IN s_waerk

    AND f~vbeln IN s_vbeln " Added for ZV_INVPR_R

    AND f~erdat IN s_erdat " Added for ZV_INVPR_R

    AND p~matnr IN s_matnr " Added for ZV_INVPR_R

    AND f~kunrg IN s_kunrg " Added for ZV_INVPR_R

    AND f~bzirk IN s_bzirk " Added for ZV_INVPR_R

    AND q~ernam IN s_ernam. " Added for ZV_INVPR_R

    • NKA7077 PCR 3135-842 Improve performance Begin

    • IF SY-SUBRC = 0.

    • APPEND INT_VBRK.

    • CLEAR INT_VBRK.

    • ENDIF.

    • ENDSELECT.

    • NKA7077 PCR 3135-842 End

    • SBB8868 PCR# 3484-001 Begin

    SORT int_vbrk_2 BY vbeln posnr.

    LOOP AT int_vbrk_2.

    SELECT vbeln

    posnr

    prsdt

    FROM vbkd "Sales Document: Business Data

    APPENDING TABLE int_vbkd_2

    WHERE vbeln = int_vbrk_2-aubel

    AND posnr = int_vbrk_2-aupos.

    IF sy-subrc <> 0.

    SELECT vbeln

    posnr

    prsdt

    FROM vbkd "Sales Document: Business Data

    APPENDING TABLE int_vbkd_2

    WHERE vbeln = int_vbrk_2-aubel

    AND posnr = '000000'.

    ENDIF.

    ENDLOOP.

    SORT int_vbkd_2 BY vbeln posnr.

    • NKA7077 PCR 3135-127 End

    ENDFORM. " SELECT-VBRK-DATA

    ----


    • FORM FILL_OUTPUT_TABLE *

    ----


    • ........ *

    ----


    FORM fill_output_table.

    LOOP AT int_vbrk_2.

    IF int_vbrk_2-vbeln <> wk_prev_vbeln.

    CALL FUNCTION 'RV_PRICE_PRINT_REFRESH'

    TABLES

    tkomv = int_tab_1.

    ENDIF.

    MOVE int_vbrk_2-vbeln TO int_output_2-vbeln.

    MOVE int_vbrk_2-fkdat TO int_output_2-fkdat.

    MOVE int_vbrk_2-bstnk_vf TO int_output_2-bstnk.

    MOVE int_vbrk_2-kunag TO int_output_2-kunag.

    MOVE int_vbrk_2-auart TO int_output_2-auart.

    IF int_vbrk_2-kzwi2 = 0.

    • PRM **

    PERFORM find_item_netvalue.

    • PRM **

    ELSE.

    int_output_2-kbetr = int_vbrk_2-kzwi2.

    int_output_2-kwert = 0.

    int_output_2-ztms = 0.

    int_output_2-znodnv = 0. "PCR 3135-558

    SELECT SINGLE kwert

    INTO int_output_2-kwert

    FROM konv

    WHERE knumv = int_vbrk_2-knumv AND

    kposn = int_vbrk_2-posnr AND

    kschl = 'ZDIS'.

    SELECT SINGLE kwert

    INTO int_output_2-ztms

    FROM konv

    WHERE knumv = int_vbrk_2-knumv AND

    kposn = int_vbrk_2-posnr AND

    kschl = 'ZTMS'.

    • NKA7077 PCR 3135-558 03/13/03 Begin

    SELECT SINGLE kwert

    INTO int_output_2-znodnv

    FROM konv

    WHERE knumv = int_vbrk_2-knumv AND

    kposn = int_vbrk_2-posnr AND

    kschl = 'ZNOD'.

    • NKA7077 PCR 3135-558 End

    ENDIF.

    MOVE int_vbrk_2-posnr TO int_output_2-posnr.

    MOVE int_vbrk_2-matnr TO int_output_2-matnr.

    MOVE int_vbrk_2-fkimg TO int_output_2-fkimg.

    MOVE int_vbrk_2-prodh TO int_output_2-prodh.

    MOVE int_vbrk_2-netwr TO int_output_2-netwr.

    MOVE int_vbrk_2-vbeln TO wk_prev_vbeln.

    MOVE int_vbrk_2-wavwr TO int_output_2-wavwr. "NKA7077 PCR3135-020

    MOVE int_vbrk_2-erdat TO int_output_2-erdat. "NKA7077 PCR3135-127

    • NKA7077 PCR# 3135-127 10/16/01 Begin

    • SBB8868 PCR# 3484-001 Begin

    MOVE int_vbrk_2-kdgrp TO int_output_2-kdgrp.

    MOVE int_vbrk_2-pltyp TO int_output_2-pltyp.

    MOVE int_vbrk_2-mvgr2 TO int_output_2-mvgr2.

    MOVE int_vbrk_2-kvgr5 TO int_output_2-kvgr5.

    • NKA7077 PCR 3135-842 End

    • Move pricing date from the sales document item level

    READ TABLE int_vbkd_2 WITH KEY vbeln = int_vbrk_2-aubel

    posnr = int_vbrk_2-aupos.

    IF sy-subrc = 0.

    MOVE int_vbkd_2-prsdt TO int_output_2-prsdt.

    ELSE.

    READ TABLE int_vbkd_2 WITH KEY vbeln = int_vbrk_2-aubel

    posnr = '000000'.

    IF sy-subrc = 0.

    MOVE int_vbkd_2-prsdt TO int_output_2-prsdt.

    ENDIF.

    ENDIF.

    APPEND int_output_2.

    ENDLOOP.

    ENDFORM. " FILL_OUTPUT_TABLE

    ----


    • FORM find_item_netvalue *

    ----


    • ........ *

    ----


    FORM find_item_netvalue. "Logics added for SIR-189.

    int_output_2-kbetr = 0.

    IF int_vbrk_2-kalsm = 'ZUSAAM' AND wk_zusaam_exist = 'Y'.

    PERFORM item_function_call.

    PERFORM extract_item_value.

    ELSE.

    IF int_vbrk_2-kalsm = 'ZCANAM' AND wk_zcanam_exist = 'Y'.

    PERFORM item_function_call.

    PERFORM extract_item_value.

    ELSE.

    WRITE: / 'Not a ZUSAAM/ZCANAM Pricing Procedure: '.

    WRITE: int_vbrk_2-vbeln.

    WRITE: ' item: ', int_vbrk_2-posnr.

    ENDIF.

    ENDIF.

    ENDFORM.

    ----


    • FORM ITEM_FUNCTION_CALL *

    ----


    • ........ *

    ----


    FORM item_function_call.

    CLEAR komk.

    CLEAR komp.

    komk-mandt = sy-mandt.

    komk-belnr = int_vbrk_2-vbeln.

    komk-knumv = int_vbrk_2-knumv.

    komk-waerk = int_vbrk_2-waerk.

    komk-kalsm = int_vbrk_2-kalsm.

    komk-kappl = 'V'.

    komp-kposn = int_vbrk_2-posnr.

    CALL FUNCTION 'RV_PRICE_PRINT_ITEM'

    EXPORTING

    comm_head_i = komk

    comm_item_i = komp

    IMPORTING

    comm_head_e = komk

    comm_item_e = komp

    TABLES

    tkomv = int_tab_1

    tkomvd = int_tab_2.

    .

    ENDFORM.

    ----


    • FORM extract_item_value_us *

    ----


    • ........ *

    ----


    FORM extract_item_value.

    tab2_index = 1.

    READ TABLE int_tab_2 INDEX tab2_index.

    IF int_vbrk_2-kalsm = 'ZUSAAM'.

    WHILE int_tab_2-stunr <= wk_zusaam_stunr AND sy-subrc = 0.

    tab2_index = tab2_index + 1.

    READ TABLE int_tab_2 INDEX tab2_index.

    ENDWHILE.

    ELSE.

    IF int_vbrk_2-kalsm = 'ZCANAM'.

    WHILE int_tab_2-stunr <= wk_zcanam_stunr AND sy-subrc = 0.

    tab2_index = tab2_index + 1.

    READ TABLE int_tab_2 INDEX tab2_index.

    ENDWHILE.

    ENDIF.

    ENDIF.

    IF tab2_index > 1.

    tab2_index = tab2_index - 1.

    READ TABLE int_tab_2 INDEX tab2_index.

    ENDIF.

    IF int_vbrk_2-kalsm = 'ZCANAM' AND int_tab_2-stunr LE wk_zcanam_stunr

    .

    int_output_2-kbetr = int_tab_2-kwert.

    ELSE.

    IF int_vbrk_2-kalsm = 'ZUSAAM' AND int_tab_2-stunr LE

    wk_zusaam_stunr.

    int_output_2-kbetr = int_tab_2-kwert.

    ENDIF.

    ENDIF.

    int_output_2-kwert = 0.

    int_output_2-ztms = 0.

    int_output_2-znodnv = 0. "PCR 3135-558

    LOOP AT int_tab_1.

    IF int_tab_1-kschl = 'ZDIS' AND int_tab_1-kposn = int_vbrk_2-posnr.

    int_output_2-kwert = int_tab_1-kwert.

    ELSE.

    IF int_tab_1-kschl = 'ZTMS' AND int_tab_1-kposn =

    int_vbrk_2-posnr.

    int_output_2-ztms = int_tab_1-kwert.

    • NKA7077 PCR 3135-558 03/13/03 Begin

    ELSE.

    IF int_tab_1-kschl = 'ZNOD' AND int_tab_1-kposn = int_vbrk_2-posnr

    .

    int_output_2-znodnv = int_tab_1-kwert.

    • NKA7077 PCR 3135-558 End

    ELSE.

    IF int_tab_1-kposn > int_vbrk_2-posnr.

    EXIT.

    ENDIF.

    ENDIF. "PCR 3135-558

    ENDIF.

    ENDIF.

    ENDLOOP.

    ENDFORM.

    • YVRMNR01- FORMS

    ********************************

    • YVRSMR01 - FORMS

    *********************************

    *&----


    *

    *& Form SELECT-VBRK-DATA, concatnenate VBRP VBAK

    *----


    *

    FORM select-vbrk-data_3.

    SELECT f~kunag

    f~vkorg

    f~vbeln

    f~fkdat

    f~zterm

    f~bstnk_vf

    f~knumv

    f~kalsm

    f~inco1

    f~waerk

    q~auart

    q~kvgr5

    p~posnr

    r~kwmeng

    p~fkimg

    p~aubel

    p~aupos "NKA7077 PCR 3660-005

    p~kzwi2

    p~netwr

    p~brgew

    p~gewei

    p~matnr

    p~wavwr "NKA7077 PCR 3135-020

    INTO TABLE int_vbrk_3

    FROM vbrk AS f

    INNER JOIN vbrp AS p ON

    fvbeln = pvbeln

    INNER JOIN vbak AS q ON

    paubel = qvbeln

    INNER JOIN vbap AS r ON

    paubel = rvbeln AND

    paupos = rposnr

    WHERE f~fkart IN s_fkart

    AND f~vkorg IN s_vkorg

    AND f~fkdat IN s_fkdat

    AND f~kunag IN s_kunag

    AND f~pltyp IN s_pltyp

    AND f~kdgrp IN s_kdgrp

    AND p~kvgr5 IN s_kvgr5

    AND q~auart IN s_auart

    • AND f~kalsm IN s_kalsm

    • AND ( FKALSM = 'ZUSAAM' OR FKALSM = 'ZCANAM' ) "

    *commented on 16-Jul-07

    AND f~waerk IN s_waerk

    AND f~vbeln IN s_vbeln " Added for ZV_INVPR_R

    AND r~mvgr2 IN s_mvgr2 " Added for ZV_INVPR_R

    AND p~mvgr1 IN s_mvgr1 " Added for ZV_INVPR_R

    AND p~mvgr3 IN s_mvgr3 " Added for ZV_INVPR_R

    AND p~mvgr4 IN s_mvgr4 " Added for ZV_INVPR_R

    AND p~mvgr5 IN s_mvgr5 " Added for ZV_INVPR_R

    AND f~erdat IN s_erdat " Added for ZV_INVPR_R

    AND p~matnr IN s_matnr " Added for ZV_INVPR_R

    AND f~kunrg IN s_kunrg " Added for ZV_INVPR_R

    AND f~bzirk IN s_bzirk " Added for ZV_INVPR_R

    AND q~ernam IN s_ernam." Added for ZV_INVPR_R

    ENDFORM. " SELECT-VBRK-DATA

    **----


    *

    • FORM FILL_OUTPUT_TABLE

    *

    **----


    *

    • ........

    *

    **----


    *

    FORM fill_output_table_3.

    *

    **sort int_output by zterm vbeln kunag.

    SORT int_vbrk_3 BY vbeln.

    LOOP AT int_vbrk_3.

    • NKA7077 PCR 3660-005 07/08/02 Begin

    • Exclude those sales orders that do not meet the pricing date

    IF NOT int_vbkd_3[] IS INITIAL.

    READ TABLE int_vbkd_3 WITH KEY vbeln = int_vbrk_3-aubel

    posnr = int_vbrk_3-aupos.

    IF sy-subrc <> 0.

    READ TABLE int_vbkd_3 WITH KEY vbeln = int_vbrk_3-aubel

    posnr = '000000'.

    IF sy-subrc <> 0.

    CONTINUE.

    ENDIF.

    ENDIF.

    ENDIF.

    • NKA7077 PCR 3660-005 End

    *

    IF int_vbrk_3-vbeln <> wk_prev_vbeln_3.

    CALL FUNCTION 'RV_PRICE_PRINT_REFRESH'

    TABLES

    tkomv = int_tab_1_3.

    ENDIF.

    AT NEW knumv. "Set flag as this is executed only the first time

    wk_konv_to_be_read_3 = 'X'.

    ENDAT.

    IF int_vbrk_3-kzwi2 = 0. "Net Value - Summary Level

    PERFORM find_item_netvalue_3.

    ELSE.

    • at new knumv.

    IF wk_konv_to_be_read_3 = 'X'.

    REFRESH int_konv_3.

    CLEAR wk_konv_to_be_read_3.

    *

    SELECT kposn kschl kwert FROM konv

    INTO TABLE int_konv_3

    WHERE knumv = int_vbrk_3-knumv

    AND ( kschl = 'ZDIS'

    OR kschl = 'ZTMS'

    • NKA7077 PCR 3135-121 10/10/01 Begin

    OR kschl = 'ZFDU' "Functional Discounts

    OR kschl = 'ZFDD' "Functional Discounts

    OR kschl = 'ZEOD' "Electronic Discount

    OR kschl = 'ZDOD' "Designated Order Day

    OR kschl = 'ZDOA' "Designated Order Day

    OR kschl = 'ZQTY' "Quantity Discount

    OR kschl = 'ZHSC' ). "Small Order Charge

    • NKA7077 PCR 3135-121 End

    SORT int_konv_3.

    ENDIF.

    • endat.

    int_output_3-kbetr = int_vbrk_3-kzwi2.

    int_output_3-kwert = 0.

    int_output_3-ztms = 0.

    • NKA7077 PCR 3141-121 Begin

    int_output_3-zfdd = 0.

    int_output_3-zfdu = 0.

    int_output_3-zeod = 0.

    int_output_3-zdod = 0.

    int_output_3-zdoa = 0.

    int_output_3-zqty = 0.

    int_output_3-zhsc = 0.

    • NKA7077 PCR 3141-121 End

    CLEAR int_konv_3.

    • Blue Price

    READ TABLE int_konv_3 WITH KEY kposn = int_vbrk_3-posnr

    kschl = 'ZDIS'.

    IF sy-subrc = 0. "PCR 3135-133

    int_output_3-kwert = int_konv_3-kwert.

    ENDIF.

    • Stat. Value for Payment Terms

    READ TABLE int_konv_3 WITH KEY kposn = int_vbrk_3-posnr

    kschl = 'ZTMS'.

    IF sy-subrc = 0. "PCR 3135-133

    int_output_3-ztms = int_konv_3-kwert.

    ENDIF.

    • NKA7077 PCR 3135-121 10/10/01 Begin

    • For Functional Discount it will be either ZFDU or ZFDD, not both

    READ TABLE int_konv_3 WITH KEY kposn = int_vbrk_3-posnr

    kschl = 'ZFDU'.

    IF sy-subrc = 0.

    int_output_3-zfdu = int_konv_3-kwert.

    ENDIF.

    • Functional Discount

    READ TABLE int_konv_3 WITH KEY kposn = int_vbrk_3-posnr

    kschl = 'ZFDD'.

    IF sy-subrc = 0.

    int_output_3-zfdd = int_konv_3-kwert.

    ENDIF.

    • Electronic Discount

    READ TABLE int_konv_3 WITH KEY kposn = int_vbrk_3-posnr

    kschl = 'ZEOD'.

    IF sy-subrc = 0.

    int_output_3-zeod = int_konv_3-kwert.

    ENDIF.

    • For Designated Order it will be either ZDOD or ZDOA, not bothD

    READ TABLE int_konv_3 WITH KEY kposn = int_vbrk_3-posnr

    kschl = 'ZDOD'.

    IF sy-subrc = 0.

    int_output_3-zdod = int_konv_3-kwert.

    ENDIF.

    • Designated Order Day - ZDOA

    READ TABLE int_konv_3 WITH KEY kposn = int_vbrk_3-posnr

    kschl = 'ZDOA'.

    IF sy-subrc = 0.

    int_output_3-zdoa = int_konv_3-kwert.

    ENDIF.

    • Quantity Discount

    READ TABLE int_konv_3 WITH KEY kposn = int_vbrk_3-posnr

    kschl = 'ZQTY'.

    IF sy-subrc = 0.

    int_output_3-zqty = int_konv_3-kwert.

    ENDIF.

    • Small Order Charge

    READ TABLE int_konv_3 WITH KEY kposn = int_vbrk_3-posnr

    kschl = 'ZHSC'.

    IF sy-subrc = 0.

    int_output_3-zhsc = int_konv_3-kwert.

    ENDIF.

    • NKA7077 PCR 3135-121 End

    ENDIF.

    • Get product group external to identify non-accessory parts

    PERFORM determine_product.

    *

    MOVE int_vbrk_3-vkorg TO int_output_3-vkorg.

    MOVE int_vbrk_3-vbeln TO int_output_3-vbeln.

    *********Added to ZV_INV_R

    MOVE int_vbrk_3-posnr TO int_output_3-posnr.

    **************************

    MOVE int_vbrk_3-fkdat TO int_output_3-fkdat.

    MOVE int_vbrk_3-zterm TO int_output_3-zterm.

    MOVE int_vbrk_3-kvgr5 TO int_output_3-kvgrd.

    MOVE int_vbrk_3-bstnk_vf TO int_output_3-bstnk_vf.

    MOVE int_vbrk_3-inco1 TO int_output_3-inco1.

    MOVE int_vbrk_3-kunag TO int_output_3-kunag.

    MOVE int_vbrk_3-auart TO int_output_3-auart.

    MOVE int_vbrk_3-fkimg TO int_output_3-fkimg.

    MOVE int_vbrk_3-kwmeng TO int_output_3-kwmeng.

    MOVE int_vbrk_3-netwr TO int_output_3-netwr.

    MOVE int_vbrk_3-brgew TO int_output_3-brgew.

    MOVE int_vbrk_3-gewei TO int_output_3-gewei.

    MOVE int_vbrk_3-wavwr TO int_output_3-wavwr.

    MOVE int_vbrk_3-vbeln TO wk_prev_vbeln_3.

    *

    • NKA7077 PCR 3135-121 Begin

    • IF NOT P_DISC IS INITIAL.

    SELECT SINGLE kvgr5

    FROM knvv INTO int_output_3-kvgrc " changed for ZV_INVPR_R

    WHERE kunnr = int_output_3-kunag

    AND vkorg = int_output_3-vkorg

    AND vtweg = '01'

    AND spart = '01'.

    • CLEAR: WF_NAME1, WF_KVGR5.

    SELECT SINGLE name1

    INTO int_output_3-name1

    FROM kna1 AS a

    INNER JOIN knvv AS b ON akunnr = bkunnr

    WHERE a~kunnr = int_output_3-kunag

    AND vkorg = int_output_3-vkorg

    AND vtweg = '01'

    AND spart = '01'.

    • ENDIF.

    • NKA7077 PCR 3135-121 End

    COLLECT int_output_3. "summarize like records

    CLEAR int_output_3.

    ENDLOOP.

    ENDFORM. " FILL_OUTPUT_TABLE

    ----


    • FORM find_item_netvalue_3

    *

    ----


    • ........ *

    ----


    FORM find_item_netvalue_3. "Logics added for SIR-189.

    int_output_3-kbetr = 0.

    IF int_vbrk_3-kalsm = 'ZUSAAM' AND wk_zusaam_exist_3 = 'Y'.

    PERFORM item_function_call_3.

    PERFORM extract_item_value_3.

    ELSE.

    IF int_vbrk_3-kalsm = 'ZCANAM' AND wk_zcanam_exist_3 = 'Y'.

    PERFORM item_function_call_3.

    PERFORM extract_item_value_3.

    ENDIF.

    ENDIF.

    ENDFORM.

    ----


    • FORM ITEM_FUNCTION_CALL_3

    *

    ----


    • ........ *

    ----


    FORM item_function_call_3.

    CLEAR komk.

    CLEAR komp.

    komk-mandt = sy-mandt.

    komk-belnr = int_vbrk_3-vbeln.

    komk-knumv = int_vbrk_3-knumv.

    komk-waerk = int_vbrk_3-waerk.

    komk-kalsm = int_vbrk_3-kalsm.

    komk-kappl = 'V'.

    komp-kposn = int_vbrk_3-posnr.

    CALL FUNCTION 'RV_PRICE_PRINT_ITEM'

    EXPORTING

    comm_head_i = komk

    comm_item_i = komp

    IMPORTING

    comm_head_e = komk

    comm_item_e = komp

    TABLES

    tkomv = int_tab_1_3

    tkomvd = int_tab_2_3.

    .

    ENDFORM.

    ----


    • FORM extract_item_value_us_3

    *

    ----


    FORM extract_item_value_3.

    tab2_index_3 = 1.

    READ TABLE int_tab_2_3 INDEX tab2_index_3.

    IF int_vbrk_3-kalsm = 'ZUSAAM'.

    WHILE int_tab_2_3-stunr <= wk_zusaam_stunr_3 AND sy-subrc = 0.

    tab2_index_3 = tab2_index_3 + 1.

    READ TABLE int_tab_2_3 INDEX tab2_index_3.

    ENDWHILE.

    ELSE.

    IF int_vbrk_3-kalsm = 'ZCANAM'.

    WHILE int_tab_2_3-stunr <= wk_zcanam_stunr_3 AND sy-subrc = 0.

    tab2_index_3 = tab2_index_3 + 1.

    READ TABLE int_tab_2_3 INDEX tab2_index_3.

    ENDWHILE.

    ENDIF.

    ENDIF.

    IF tab2_index_3 > 1.

    tab2_index_3 = tab2_index_3 - 1.

    READ TABLE int_tab_2_3 INDEX tab2_index_3.

    ENDIF.

    IF int_vbrk_3-kalsm = 'ZCANAM' AND int_tab_2_3-stunr LE

    wk_zcanam_stunr_3.

    int_output_3-kbetr = int_tab_2_3-kwert.

    ELSE.

    IF int_vbrk_3-kalsm = 'ZUSAAM' AND int_tab_2_3-stunr LE

    wk_zusaam_stunr_3.

    int_output_3-kbetr = int_tab_2_3-kwert.

    ENDIF.

    ENDIF.

    int_output_3-kwert = 0.

    int_output_3-ztms = 0.

    • NKA7077 PCR 3135-121 Begin

    int_output_3-zfdu = 0.

    int_output_3-zfdd = 0.

    int_output_3-zeod = 0.

    int_output_3-zdod = 0.

    int_output_3-zdoa = 0.

    int_output_3-zqty = 0.

    int_output_3-zhsc = 0.

    • NKA7077 PCR 3135-121 End

    LOOP AT int_tab_1_3.

    IF int_tab_1_3-kschl = 'ZDIS' AND int_tab_1_3-kposn =

    int_vbrk_3-posnr.

    int_output_3-kwert = int_tab_1_3-kwert.

    ELSE.

    IF int_tab_1_3-kschl = 'ZTMS' AND int_tab_1_3-kposn =

    int_vbrk_3-posnr.

    int_output_3-ztms = int_tab_1_3-kwert.

    • NKA7077 PCR 3135-121 10/10/01 Begin

    • For Functional Discount it will be either ZFDU or ZFDD, not both

    ELSE.

    IF int_tab_1_3-kschl = 'ZFDU' AND int_tab_1_3-kposn =

    int_vbrk_3-posnr.

    int_output_3-zfdu = int_tab_1_3-kwert.

    • Move Functional Discount - ZFDD

    ELSE.

    IF int_tab_1_3-kschl = 'ZFDD' AND int_tab_1_3-kposn =

    int_vbrk_3-posnr.

    int_output_3-zfdd = int_tab_1_3-kwert.

    • Move Electronic Discount

    ELSE.

    IF int_tab_1_3-kschl = 'ZEOD' AND int_tab_1_3-kposn =

    int_vbrk_3-posnr.

    int_output_3-zeod = int_tab_1_3-kwert.

    • Move Designated Order Day - ZDOD

    ELSE.

    IF int_tab_1_3-kschl = 'ZDOD' AND int_tab_1_3-kposn =

    int_vbrk_3-posnr.

    int_output_3-zdod = int_tab_1_3-kwert.

    • Move Designated Order Day - ZDOA

    ELSE.

    IF int_tab_1_3-kschl = 'ZDOA' AND int_tab_1_3-kposn =

    int_vbrk_3-posnr.

    int_output_3-zdoa = int_tab_1_3-kwert.

    • Move Quantity Discount

    ELSE.

    IF int_tab_1_3-kschl = 'ZQTY' AND int_tab_1_3-kposn =

    int_vbrk_3-posnr.

    int_output_3-zqty = int_tab_1_3-kwert.

    • Move Small Order Charge

    ELSE.

    IF int_tab_1_3-kschl = 'ZHSC' AND int_tab_1_3-kposn =

    int_vbrk_3-posnr

    .

    int_output_3-zhsc = int_tab_1_3-kwert.

    • NKA7077 PCR 3135-121 End

    ELSE.

    IF int_tab_1_3-kposn > int_vbrk_3-posnr.

    EXIT.

    ENDIF.

    ENDIF.

    ENDIF. "PCR 3135-121

    ENDIF. "PCR 3135-121

    ENDIF. "PCR 3135-121

    ENDIF. "PCR 3135-121

    ENDIF. "PCR 3135-121

    ENDIF. "PCR 3135-121

    ENDIF. "PCR 3135-121

    ENDIF. "PCR 3135-121

    ENDLOOP.

    ENDFORM.

    *&----


    *

    *& Form DETERMINE_PRODUCT

    *&----


    *

    • text

    *----


    *

    FORM determine_product.

    CLEAR: wf_product_3, wf_product_type_3.

    • Get the external product group from the classification view

    SELECT SINGLE atwrt INTO wf_product_3 FROM zv_aiag

    WHERE objek = int_vbrk_3-matnr

    AND class = 'WALKER-LEGACY'

    AND atnam = 'PRODUCT-GROUP-EXTERNAL'

    AND klart = '001'.

    • If no classification view, then get it from the product hierarchy

    IF sy-subrc <> 0.

    SELECT SINGLE prdha INTO wf_product_type_3 FROM mara

    WHERE matnr = int_vbrk_3-matnr.

    MOVE wf_product_type_3+5(1) TO wf_product_3.

    ENDIF.

    • Add quantity to non accessory total if part is not an accessory.

    IF wf_product_3 <> 'A'.

    int_output_3-nonacc = int_output_3-nonacc + int_vbrk_3-kwmeng.

    ENDIF.

    ENDFORM. " DETERMINE_PRODUCT

    *----


    *

    • Form SELECT_VBKD_DATA_3

    *----


    *

    • Select billing docs based on sales order pricing date

    *----


    *

    FORM select_vbkd_data_3.

    IF NOT s_erdat-low IS INITIAL.

    • Select all sales orders with the pricing date on selection screen

    SELECT vbeln

    posnr

    FROM vbkd

    INTO TABLE int_vbkd_3

    FOR ALL ENTRIES IN int_vbrk_3

    WHERE vbeln = int_vbrk_3-aubel

    • and posnr = int_vbrk-aupos

    AND prsdt IN s_erdat.

    ENDIF.

    ENDFORM.

    • YVRSMR01 - FORMS

    *********************************

    • ZV_INVPR_R - FORMS

    *******************************

    *&----


    *

    *& Form get_pricon_text

    *&----


    *

    • text

    *----


    *

    • --> p1 text

    • <-- p2 text

    *----


    *

    FORM get_pricon_text.

    SELECT kschl vtext FROM t685t

    INTO TABLE t_condes

    WHERE spras = 'EN'.

    ENDFORM. " get_pricon_text

    • ZV_INVPR_R - FORMS

    *******************************

    • ALV - SLIS - FORMS

    *******************************

    *&----


    *

    *& Form pre_cat

    *&----


    *

    • text

    *----


    *

    • --> p1 text

    • <-- p2 text

    *----


    *

    FORM pre_cat.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'P_NAME1'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Payer Name'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'KUNGR'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Payer Number'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'FKART'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Billing Doc Type'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'BZIRK'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Sales District'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    ****************************June 19th 2007 byX1MEENMP****************

    *v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'VTEXT'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'Pricing Condition:Name'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    • COMMENTED BY RAMA MURTHY ON 20-07-2007 **

    • v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'VPRS1'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'VPRS'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    *

    *

    • v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'ZANT'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'ZANT'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    *

    **v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'ZCDS'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'ZCDS'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    *

    • v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'ZCOM'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'ZCOM'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    *

    • v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'ZCOS'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'ZCOS'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    *

    *

    • v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'ZDFT'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'ZDFT'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    *

    • v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'ZDIS1'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'ZDIS'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    *

    • v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'ZFDD'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'ZFDD'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    *

    • v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'ZINC'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'ZINC'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    *

    • v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'ZL1D'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'ZL1D'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    *

    • v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'ZL2D'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'ZL2D'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    *

    • v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'ZL3D'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'ZL3D'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    *

    • v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'ZL4D'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'ZL4D'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    *

    • v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'ZQYD'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'ZQYD'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    *

    • v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'ZRDD'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'ZRDD'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    *

    • v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'ZTMS1'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'ZTMS'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    *

    • v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'ZTWC'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'ZTWC'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    *

    • v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'ZWCA'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'ZWCA'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    *

    • v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'ZNOD1'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'ZNOD'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    *

    • v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'SKTV'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'SKTV'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    *

    • v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'ZCAL'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'ZCAL'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    *

    • v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'ZBTS'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'ZBTS'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    *

    • v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'ZSSC'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'ZSSC'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    ********************************************************************

    *v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'VTEXT'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'Pricing Condition:Name'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    *

    *v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'KWERT'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'Condition Amount'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    ****************************June 19th 2007 byX1MEENMP****************

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'PLTYP'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Price List Type'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'ERNAM'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'User ID'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'NAME1'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Sold To Name'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'KVGRC'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Current Trade Class'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'KVGRD'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Doc Trade Class'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'AUART'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Doc Type'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'KWMENG'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Order Quantity'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'FKIMG'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Bill Quantity'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'NONACC'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Non Acc Order Quantity'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'BRGEW'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Gross Weight'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'KDGRP'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Customer Group'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'POSNR'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Item Number'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'PRSDT'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Pricing Date'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'MVGR2'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Product Identifier'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'ZNODNV'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'ZNOD Net Value'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'SOLD'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Sold To'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'BILL'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Bill To'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'SHIP'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Ship To'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    • DO NOT UNCOMMENT ******************************

    *

    **v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'ORT01'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'Ship To Address:City'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    **

    **v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'PSTLZ'.

    • wafieldcatlog1-tabname = 'T_MAIN'.

    • wafieldcatlog1-seltext_l = 'Ship To Address:Postal Code'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    **************************************************************

    *

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'SHIPADDR'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Ship To Address'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'WAERK'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Currency'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'VBELN'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Billing Document'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'FKDAT'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Billing Date'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'AUBEL'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Sales Doc Number'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'ERDAT'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Created On Date'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'XBLNR'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'PO'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'MATNR'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Material Number'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'ZTERM'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Payment Terms'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'NTGEW'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Net Weight'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'KZWI2'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Net Value Before Adj'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'NETWR'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Net Value After Adj'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'HZTMS'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'ZTMS Total'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'PRODH'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Product Hierarchy'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    • ***

    • COMMENTED ON 26-07-2007 AS INSTRUCTED BY TIM **

    • ***

    • v_index = v_index + 1.

    • wafieldcatlog1-fieldname = 'KVGR5'.

    • wafieldcatlog1-tabname = '<dyn_table>'.

    • wafieldcatlog1-seltext_l = 'Trade Class'.

    • wafieldcatlog1-hotspot = ' '.

    • wafieldcatlog1-col_pos = v_index.

    • append wafieldcatlog1 to it_fieldcatalog1.

    • clear wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'VGBEL'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Delivery Number'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'INCO1'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Delv Terms'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'LNAME1'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Carrier'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'BOLNR'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'BOL'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'WADAT'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Ship Date'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'WAVWR'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Cost'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    ****************************************************************

    • FIELD NAMES CHANGED TO ZDIS1 ZTMS1 ZNOD1 FROM ZDIS ZTMS ZNOD *

    ****************************************************************

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'ZDIS1'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'Blue Price - ZDIS Value'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'ZTMS1'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'ZTMS Value'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    v_index = v_index + 1.

    wafieldcatlog1-fieldname = 'ZNOD1'.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = 'ZNOD Value'.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    ****************************************************************

    • CODED BY RAMA MURTHY **

    • ***

  • REMOVING THE DYNAMIC CONDITION RECORDS COLUMNS WITH NO CONTENT *

    • ***

    DATA: dyn_count TYPE i,

    count TYPE i.

    FIELD-SYMBOLS: <fs4>.

    DESCRIBE TABLE <dyn_table> LINES dyn_count.

    v_index_new = v_index.

    LOOP AT i_kschl .

    CLEAR count.

    LOOP AT <dyn_table> INTO <dyn_wa>.

    ASSIGN COMPONENT i_kschl-kschl OF STRUCTURE <dyn_wa> TO <fs4>.

    IF ( ( <fs4> IS INITIAL ) OR ( <fs4> EQ 0 ) ).

    count = count + 1.

    ELSE.

    CLEAR count.

    EXIT.

    ENDIF.

    ENDLOOP.

    IF count EQ dyn_count.

    CONTINUE.

    ELSE.

    • v_index_new = v_index.

    *

    • loop at i_kschl.

    v_index_new = v_index_new + 1.

    wafieldcatlog1-fieldname = i_kschl-kschl.

    wafieldcatlog1-tabname = '<dyn_table>'.

    wafieldcatlog1-seltext_l = i_kschl-kschl.

    wafieldcatlog1-hotspot = ' '.

    wafieldcatlog1-col_pos = v_index_new.

    APPEND wafieldcatlog1 TO it_fieldcatalog1.

    CLEAR wafieldcatlog1-key.

    • endloop.

    ENDIF.

    ENDLOOP.

    v_index_cond = v_index_new - v_index.

    ENDFORM.

    • ALV - SLIS - FORMS

    ----


    • FORM build_dyn_itab *

    ----


    • ........ *

    ----


    FORM build_dyn_itab.

    DATA: new_table TYPE REF TO data,

    new_line TYPE REF TO data,

    wa_it_fldcat TYPE lvc_s_fcat.

    • COLUMN COUNT TO CREATE DYNAMIC INTERNAL TABLE **

    DATA: v_colpos TYPE i,

    v_colpos_new TYPE i.

    • LOADING THE DYNAMIC FIELD CATELOG TO BE PASSED **

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'VBELN'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 10.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'P_NAME1'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 35.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'KUNGR'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 10.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'FKART'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 4.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'BZIRK'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 6.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'PLTYP'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 2.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'ERNAM'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 12.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'NAME1'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 35.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'KVGRC'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 3.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'KVGRD'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 3.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'AUART'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 4.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'KWMENG'.

    wa_it_fldcat-datatype = 'QUAN'.

    wa_it_fldcat-intlen = 19.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'FKIMG'.

    wa_it_fldcat-datatype = 'QUAN'.

    wa_it_fldcat-intlen = 17.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'NONACC'.

    wa_it_fldcat-datatype = 'QUAN'.

    wa_it_fldcat-intlen = 19.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'BRGEW'.

    wa_it_fldcat-datatype = 'QUAN'.

    wa_it_fldcat-intlen = 19.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'KDGRP'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 2.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'POSNR'.

    wa_it_fldcat-datatype = 'NUMC'.

    wa_it_fldcat-intlen = 6.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'PRSDT'.

    wa_it_fldcat-datatype = 'DATS'.

    wa_it_fldcat-intlen = 10.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'MVGR2'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 3.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'ZNODNV'.

    wa_it_fldcat-datatype = 'CURR'.

    wa_it_fldcat-intlen = 18.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'SOLD'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 10.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'BILL'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 10.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'SHIP'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 10.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'SHIPADDR'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 45.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'WAERK'.

    wa_it_fldcat-datatype = 'CUKY'.

    wa_it_fldcat-intlen = 5.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'FKDAT'.

    wa_it_fldcat-datatype = 'DATS'.

    wa_it_fldcat-intlen = 10.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'AUBEL'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 10.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'ERDAT'.

    wa_it_fldcat-datatype = 'DATS'.

    wa_it_fldcat-intlen = 10.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'XBLNR'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 16.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'MATNR'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 18.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'ZTERM'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 4.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'NTGEW'.

    wa_it_fldcat-datatype = 'QUAN'.

    wa_it_fldcat-intlen = 19.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'KZWI2'.

    wa_it_fldcat-datatype = 'CURR'.

    wa_it_fldcat-intlen = 18.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'NETWR'.

    wa_it_fldcat-datatype = 'CURR'.

    wa_it_fldcat-intlen = 21.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'HZTMS'.

    wa_it_fldcat-datatype = 'CURR'.

    wa_it_fldcat-intlen = 18.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'PRODH'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 18.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'KVGR5'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 3.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'VGBEL'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 10.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'INCO1'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 3.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'LNAME1'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 35.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'BOLNR'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 35.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'WADAT'.

    wa_it_fldcat-datatype = 'DATS'.

    wa_it_fldcat-intlen = 10.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'WAVWR'.

    wa_it_fldcat-datatype = 'CURR'.

    wa_it_fldcat-intlen = 18.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'ZDIS1'.

    wa_it_fldcat-datatype = 'CURR'.

    wa_it_fldcat-intlen = 21.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'ZTMS1'.

    wa_it_fldcat-datatype = 'CURR'.

    wa_it_fldcat-intlen = 21.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'ZNOD1'.

    wa_it_fldcat-datatype = 'CURR'.

    wa_it_fldcat-intlen = 21.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos = v_colpos + 1.

    wa_it_fldcat-col_pos = v_colpos.

    wa_it_fldcat-fieldname = 'FLAGK'.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 1.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    v_colpos_new = v_colpos.

    • CREATE DYNAMIC FIELD COLUMNS **

    LOOP AT i_kschl.

    v_colpos_new = v_colpos_new + 1.

    wa_it_fldcat-col_pos = v_colpos_new.

    wa_it_fldcat-fieldname = i_kschl-kschl.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 4.

    APPEND wa_it_fldcat TO it_fldcat .

    CLEAR wa_it_fldcat.

    CLEAR i_kschl.

    ENDLOOP.

    • METHOD USED TO OBTAIN DYNAMIC INTERNAL TABLE AS PER CATELOG **

    CALL METHOD cl_alv_table_create=>create_dynamic_table

    EXPORTING

    • I_STYLE_TABLE =

    it_fieldcatalog = it_fldcat

    IMPORTING

    ep_table = new_table

    • E_STYLE_FNAME =

    EXCEPTIONS

    generate_subpool_dir_full = 1

    OTHERS = 2.

    IF sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    ASSIGN new_table->* TO <dyn_table>.

    CREATE DATA new_line LIKE LINE OF <dyn_table>.

    ASSIGN new_line->* TO <dyn_wa>.

    ENDFORM.

    *******************************

    ----


    • FORM filter_dyn_table *

    ----


    • ........ *

    ----


    FORM filter_dyn_table.

    FIELD-SYMBOLS: <fs3> TYPE ANY.

    SORT <dyn_table> BY ('MATNR').

    LOOP AT <dyn_table> INTO <dyn_wa>.

    UNASSIGN <fs3>.

    ASSIGN COMPONENT 'MATNR' OF STRUCTURE <dyn_wa> TO <fs3>.

    IF NOT <fs3> IN s_matnr.

    DELETE TABLE <dyn_table> FROM <dyn_wa>.

    ENDIF.

    ENDLOOP.

    SORT <dyn_table> BY ('KVGR5').

    LOOP AT <dyn_table> INTO <dyn_wa>.

    UNASSIGN <fs3>.

    ASSIGN COMPONENT 'KVGR5' OF STRUCTURE <dyn_wa> TO <fs3>.

    IF NOT <fs3> IN s_kvgr5.

    DELETE TABLE <dyn_table> FROM <dyn_wa>.

    ENDIF.

    ENDLOOP.

    LOOP AT <dyn_table> INTO <dyn_wa>.

    UNASSIGN <fs3>.

    ASSIGN COMPONENT 'FLAGK' OF STRUCTURE <dyn_wa> TO <fs3>.

    IF NOT <fs3> EQ 'X'.

    DELETE TABLE <dyn_table> FROM <dyn_wa>.

    ENDIF.

    ENDLOOP.

    ENDFORM.

    If you still have any doubdo

  • avatar image
    Former Member
    Sep 04, 2008 at 09:47 AM

    hi,

    Pls check this CHECK TABLE for condition types- T685 from this table based on application area we can get the condition types.

    Regards

    Lekha

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 04, 2008 at 09:53 AM

    hi,

    try this...

    data:

    i_output type ref to data.

    field-symbols:

    <fs_output> type table,

    <fwa_otput> type any,

    <fs_field> type any.

    DEFINE dfn_fldct.

    add 1 to lwa_fldct-col_pos.

    lwa_fldct-fieldname = &1.

    lwa_fldct-do_sum = &2.

    lwa_fldct-reptext = &3.

    lwa_fldct-coltext = &3.

    lwa_fldct-datatype = &4.

    lwa_fldct-outputlen = &5.

    lwa_fldct-decimals_o = &6.

    lwa_fldct-just = &7.

    lwa_fldct-ref_table = &8.

    append lwa_fldct to i_fldct.

    END-OF-DEFINITION.

    sort itab by kschl.

    loop at itab into wa_itab.

    at new kschl.

    dfn_fldct: wa_itab-kschl '' '' 'CHAR' 12 0 'R' ''.

    endat.

    endloop.

    CALL METHOD cl_alv_table_create=>create_dynamic_table

    EXPORTING

    it_fieldcatalog = i_fldct

    IMPORTING

    ep_table = i_output

    EXCEPTIONS

    generate_subpool_dir_full = 1

    OTHERS = 2.

    assign i_output->* to <fs_output>.

    loop at <fs_output> assign <fwa_otput>.

    loop at itab into wa_itab.

    at new kschl.

    assign component wa_itab-kschl of structure <fwa_otput> to <fs_field>.

    write: / <fs_field>.

    endat.

    endloop.

    endloop.

    regards,

    Peter

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 04, 2008 at 09:54 AM

    hi,

    try this...

    data:

    i_output type ref to data.

    field-symbols:

    <fs_output> type table,

    <fwa_otput> type any,

    <fs_field> type any.

    DEFINE dfn_fldct.

    add 1 to lwa_fldct-col_pos.

    lwa_fldct-fieldname = &1.

    lwa_fldct-do_sum = &2.

    lwa_fldct-reptext = &3.

    lwa_fldct-coltext = &3.

    lwa_fldct-datatype = &4.

    lwa_fldct-outputlen = &5.

    lwa_fldct-decimals_o = &6.

    lwa_fldct-just = &7.

    lwa_fldct-ref_table = &8.

    append lwa_fldct to i_fldct.

    END-OF-DEFINITION.

    sort itab by kschl.

    loop at itab into wa_itab.

    at new kschl.

    dfn_fldct: wa_itab-kschl '' '' 'CHAR' 12 0 'R' ''.

    endat.

    endloop.

    CALL METHOD cl_alv_table_create=>create_dynamic_table

    EXPORTING

    it_fieldcatalog = i_fldct

    IMPORTING

    ep_table = i_output

    EXCEPTIONS

    generate_subpool_dir_full = 1

    OTHERS = 2.

    assign i_output->* to <fs_output>.

    loop at <fs_output> assign <fwa_otput>.

    loop at itab into wa_itab.

    at new kschl.

    assign component wa_itab-kschl of structure <fwa_otput> to <fs_field>.

    write: / <fs_field>.

    endat.

    endloop.

    endloop.

    regards,

    Peter

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi peter,

      Thanks for ur reply. Kindly send send me full code, with all required declaration.

      Thanks in advance.

      Regards,

      s.senthil kumar