Dear Friends,
Recently I had a requirement to create Material consumption , Purchase Condition price , Purchase a material from particular vendor based on the month wise report . Its is created using dynamic internal table .
Logic used:
1.Material,Vendor,Purchase price will be in first row.
2. Consumption price will be in 2nd row if purchase price is available else Consumption price will be in first row.
3. Logic I Used for raw material consumption and purchase details hot coded in the select query.
Dynamic Internal Table :
REPORT zvendor_purchase_report MESSAGE-ID zvpr.
TYPE-POOLS: slis.
TABLES: mseg, mara.
TYPES: BEGIN OF ty_period,
period(6) TYPE c,
END OF ty_period,
BEGIN OF ty_out,
month(2) TYPE c,
year(4) TYPE c,
mblnr TYPE mkpf-mblnr,
budat TYPE mkpf-budat,
knumv TYPE ekko-knumv,
bwart TYPE mseg-bwart,
matnr TYPE mseg-matnr,
menge TYPE mseg-menge,
tot_cons TYPE mseg-menge,
maktx TYPE makt-maktx,
lifnr TYPE mseg-lifnr,
name1 TYPE lfa1-name1,
kschl TYPE konv-kschl,
price(15) TYPE c,
kbetr TYPE konv-kbetr,
END OF ty_out,
BEGIN OF ty_output,
month(2) TYPE c,
year(4) TYPE c,
matnr TYPE mseg-matnr,
maktx TYPE makt-maktx,
lifnr TYPE ekko-lifnr,
name1 TYPE lfa1-name1,
price(15) TYPE c,
kbetr TYPE konv-kbetr,
menge TYPE mseg-menge,
tot_consum TYPE mseg-menge,
budat TYPE mkpf-budat,
mblnr TYPE mkpf-mblnr,
END OF ty_output,
BEGIN OF ty_price,
knumv TYPE ekko-knumv,
kschl TYPE konv-kschl,
kbetr TYPE konv-kbetr,
END OF ty_price,
BEGIN OF ty_pur_qty,
knumv TYPE ekko-knumv,
kschl TYPE konv-kschl,
kbetr TYPE konv-kbetr,
END OF ty_pur_qty,
BEGIN OF ty_months,
month(2) TYPE c,
month_name(3) TYPE c,
year(4) TYPE c,
END OF ty_months,
BEGIN OF ty_mseg,
month(2) TYPE c,
year(4) TYPE c,
budat TYPE mkpf-budat,
matnr TYPE mseg-matnr,
menge TYPE mseg-menge,
END OF ty_mseg,
BEGIN OF ty_matnr,
matnr TYPE mseg-matnr,
END OF ty_matnr.
DATA: wa_period TYPE ty_period,
gt_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE LINE OF slis_t_fieldcat_alv,
gt_fieldout TYPE slis_t_fieldcat_alv,
wa_fieldout TYPE LINE OF slis_t_fieldcat_alv,
gt_field TYPE lvc_t_fcat,
wa_field TYPE lvc_s_fcat,
gt_out TYPE TABLE OF ty_out,
wa_out TYPE ty_out,
gt_output TYPE TABLE OF ty_output,
wa_output TYPE ty_output,
gt_output1 TYPE TABLE OF ty_output,
wa_output1 TYPE ty_output,
gt_output5 TYPE TABLE OF ty_output,
wa_output5 TYPE ty_output,
wa_output2 TYPE ty_output,
gt_months TYPE TABLE OF ty_months,
wa_months TYPE ty_months,
gt_price TYPE TABLE OF ty_price,
wa_price TYPE ty_price,
gt_mseg TYPE TABLE OF ty_mseg,
wa_mseg TYPE ty_mseg,
gt_261 TYPE TABLE OF ty_mseg,
wa_261 TYPE ty_mseg,
gt_matnr TYPE TABLE OF ty_matnr,
wa_matnr TYPE ty_matnr.
DATA: gv_months TYPE vtbbewe-atage,
gv_low_date TYPE sy-datum,
gv_high_date TYPE sy-datum,
gv_po_date_low TYPE sy-datum,
gv_po_date_high TYPE sy-datum.
FIELD-SYMBOLS: <gfs_table> TYPE STANDARD TABLE,
<gfs_table1> TYPE STANDARD TABLE.
PARAMETERS: p_werks TYPE mseg-werks OBLIGATORY.
PARAMETERS: p_low(6) TYPE c OBLIGATORY,
p_high(6) TYPE c OBLIGATORY.
SELECT-OPTIONS: s_matnr FOR mseg-matnr.
AT SELECTION-SCREEN.
IF NOT p_werks IS INITIAL.
*-- Validate Plant
PERFORM plant.
*-- Check Plant Authorization
AUTHORITY-CHECK OBJECT 'ZP_WERKS'
ID 'P_WERKS' FIELD p_werks.
IF sy-subrc NE 0.
MESSAGE e001(zvpr) WITH p_werks.
ENDIF.
ENDIF.
START-OF-SELECTION.
PERFORM get_months.
PERFORM build_fieldcat.
PERFORM get_data.
PERFORM display_out.
*&---------------------------------------------------------------------*
*& Form GET_PERIOD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_months .
DATA: lv_ktx TYPE t247-ktx.
CONCATENATE p_low '01' INTO gv_low_date.
CONCATENATE p_high '01' INTO gv_high_date.
CALL FUNCTION 'SG_PS_GET_LAST_DAY_OF_MONTH'
EXPORTING
day_in = gv_high_date
IMPORTING
last_day_of_month = gv_high_date
EXCEPTIONS
day_in_not_valid = 1
OTHERS = 2.
gv_po_date_low = gv_low_date.
gv_po_date_high = gv_high_date.
CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
EXPORTING
i_date_from = gv_low_date
i_date_to = gv_high_date
IMPORTING
* E_DAYS =
e_months = gv_months
* E_YEARS =
.
gv_low_date+4(2) = gv_low_date+4(2) - 1.
DO gv_months TIMES.
gv_low_date+4(2) = gv_low_date+4(2) + 1.
IF gv_low_date+4(2) = 13.
gv_low_date+0(4) = gv_low_date+0(4) + 1.
gv_low_date+4(2) = 1.
ENDIF.
CLEAR: lv_ktx.
SELECT SINGLE ktx INTO lv_ktx FROM t247
WHERE spras = sy-langu
AND mnr = gv_low_date+4(2).
wa_months-month = gv_low_date+4(2).
wa_months-month_name = lv_ktx.
wa_months-year = gv_low_date+0(4).
APPEND wa_months TO gt_months.
ENDDO.
ENDFORM. "GET_months
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM build_fieldcat .
*-> Build Field catalog
CLEAR: wa_fieldcat.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-seltext_l = 'Material Code'.
wa_fieldcat-tabname = 'GT_OUTPUT'.
wa_fieldcat-outputlen = 25.
wa_fieldcat-key = 'X'.
APPEND wa_fieldcat TO gt_fieldcat.
CLEAR: wa_fieldcat.
wa_fieldcat-fieldname = 'MAKTX'.
wa_fieldcat-seltext_l = 'Material Description'.
wa_fieldcat-tabname = 'GT_OUTPUT'.
wa_fieldcat-outputlen = 30.
wa_fieldcat-key = 'X'.
APPEND wa_fieldcat TO gt_fieldcat.
CLEAR: wa_fieldcat.
wa_fieldcat-fieldname = 'LIFNR'.
wa_fieldcat-seltext_l = 'Vendor Number'.
wa_fieldcat-tabname = 'GT_OUTPUT'.
wa_fieldcat-outputlen = 15.
wa_fieldcat-key = 'X'.
APPEND wa_fieldcat TO gt_fieldcat.
CLEAR: wa_fieldcat.
wa_fieldcat-fieldname = 'NAME1'.
wa_fieldcat-seltext_l = 'Name of the Vendor'.
wa_fieldcat-tabname = 'GT_OUTPUT'.
wa_fieldcat-outputlen = 50.
APPEND wa_fieldcat TO gt_fieldcat.
CLEAR: wa_months.
LOOP AT gt_months INTO wa_months.
CLEAR: wa_fieldcat.
CONCATENATE wa_months-month_name wa_months-year '_' 'PRICE' INTO wa_fieldcat-fieldname.
CONCATENATE wa_months-month_name wa_months-year '-' 'Price' INTO wa_fieldcat-seltext_l.
wa_fieldcat-tabname = 'GT_OUTPUT'.
wa_fieldcat-ref_tabname = 'KONV'.
wa_fieldcat-ref_fieldname = 'KBETR'.
wa_fieldcat-outputlen = 25.
APPEND wa_fieldcat TO gt_fieldcat.
CLEAR: wa_fieldcat.
CONCATENATE wa_months-month_name wa_months-year '_' 'PUR_QTY' INTO wa_fieldcat-fieldname.
CONCATENATE wa_months-month_name wa_months-year '-' 'Purchase Quantity' INTO wa_fieldcat-seltext_l.
wa_fieldcat-tabname = 'GT_OUTPUT'.
wa_fieldcat-ref_tabname = 'MSEG'.
wa_fieldcat-ref_fieldname = 'menge'.
wa_fieldcat-outputlen = 25.
APPEND wa_fieldcat TO gt_fieldcat.
CLEAR: wa_fieldcat.
CONCATENATE wa_months-month_name wa_months-year '_' 'TOT_CONSUM' INTO wa_fieldcat-fieldname.
CONCATENATE wa_months-month_name wa_months-year '-' 'Total Consumption' INTO wa_fieldcat-seltext_l.
wa_fieldcat-tabname = 'GT_OUTPUT'.
wa_fieldcat-ref_tabname = 'MSEG'.
wa_fieldcat-ref_fieldname = 'menge'.
* wa_fieldcat-do_sum = 'X'.
wa_fieldcat-outputlen = 25.
APPEND wa_fieldcat TO gt_fieldcat.
ENDLOOP.
ENDFORM. " BUILD_FIELDCAT
*&---------------------------------------------------------------------*
*& Form DISPLAY_OUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM display_out .
DATA: lt_sort TYPE slis_t_sortinfo_alv,
lwa_sort TYPE LINE OF slis_t_sortinfo_alv.
CLEAR: lwa_sort.
lwa_sort-fieldname = 'MATNR'.
lwa_sort-up = 'X'.
APPEND lwa_sort TO lt_sort.
CLEAR: lwa_sort.
lwa_sort-fieldname = 'MAKTX'.
lwa_sort-down = 'X'.
APPEND lwa_sort TO lt_sort.
CLEAR: lwa_sort.
lwa_sort-fieldname = 'LIFNR'.
lwa_sort-up = 'X'.
APPEND lwa_sort TO lt_sort.
CLEAR: lwa_sort.
lwa_sort-fieldname = 'NAME1'.
lwa_sort-up = 'X'.
APPEND lwa_sort TO lt_sort.
IF <gfs_table> IS INITIAL.
MESSAGE s000(zvpr) WITH 'No data to display!'.
ELSEIF <gfs_table> IS NOT INITIAL.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_save = 'X'
it_sort = lt_sort
it_fieldcat = gt_fieldcat
TABLES
t_outtab = <gfs_table>.
ENDIF.
ENDFORM. " DISPLAY_OUT
*&---------------------------------------------------------------------*
*& Form plant
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM plant .
DATA l_werks TYPE werks_d.
IF l_werks IS INITIAL.
CLEAR l_werks.
ENDIF.
SELECT SINGLE werks
FROM t001w
INTO l_werks
WHERE werks EQ p_werks.
IF sy-subrc NE 0.
*Error Message (Enter a valid plant)
MESSAGE e002(zvpr).
ENDIF.
ENDFORM. " PLANT
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_data .
DATA: lt_dyntab TYPE REF TO data,
lwa_dyntab TYPE REF TO data,
lt_dyntab1 TYPE REF TO data,
lwa_dyntab1 TYPE REF TO data,
lv_ktx TYPE t247-ktx,
lv_kbetr TYPE konv-kbetr,
lv_menge TYPE mseg-menge,
lv_tot_cons TYPE mseg-menge,
lv_lifnr(15) TYPE c VALUE 'LIFNR',
lv_matnr(18) TYPE c VALUE 'MATNR',
lv_pur_qty(20) TYPE c,
lv_price(20) TYPE c,
lv_tot_consum(20) TYPE c,
lv_year(4) TYPE c,
lv_tabix TYPE sy-tabix,
lv_index TYPE sy-index,
lv_lines TYPE i,
lv_delete TYPE c,
lv_no_star TYPE c.
FIELD-SYMBOLS : <lfs_wa> TYPE ANY,
<lfs_wa1> TYPE ANY,
<lfs_fld> TYPE ANY,
<lfs_matnr> TYPE ANY,
<lfs_maktx> TYPE ANY,
<lfs_lifnr> TYPE ANY,
<lfs_name1> TYPE ANY,
<lfs_tot> TYPE ANY.
CLEAR: gt_out.
SELECT mkpf~mblnr mkpf~budat mseg~bwart mseg~matnr mseg~lifnr mseg~menge mseg~ebeln
mkpf~budat
ekko~knumv
makt~maktx
lfa1~name1
INTO CORRESPONDING FIELDS OF TABLE gt_out FROM mseg AS mseg
INNER JOIN mkpf AS mkpf ON mkpf~mblnr = mseg~mblnr AND mkpf~mjahr = mseg~mjahr
INNER JOIN ekko AS ekko ON ekko~ebeln = mseg~ebeln
INNER JOIN makt AS makt ON makt~matnr = mseg~matnr
INNER JOIN lfa1 AS lfa1 ON lfa1~lifnr = mseg~lifnr AND lfa1~spras = 'EN'
INNER JOIN mara AS mara ON mara~matnr = mseg~matnr
WHERE mkpf~budat GE gv_po_date_low AND mkpf~budat LE gv_po_date_high
AND mara~mtart = 'ROH'
AND mseg~matnr IN s_matnr
AND mseg~werks = p_werks
AND mseg~bwart = '101'.
IF gt_out IS NOT INITIAL.
SELECT knumv
kschl
kbetr
INTO CORRESPONDING FIELDS OF TABLE gt_price
FROM konv FOR ALL ENTRIES IN gt_out
WHERE knumv = gt_out-knumv
AND kschl = 'P000'.
ENDIF.
CLEAR: gt_mseg.
SELECT mseg~matnr mseg~lifnr mseg~menge mkpf~budat
INTO CORRESPONDING FIELDS OF TABLE gt_mseg
FROM mseg AS mseg
INNER JOIN mkpf AS mkpf ON mkpf~mblnr = mseg~mblnr AND mkpf~mjahr = mseg~mjahr
INNER JOIN mara AS mara ON mara~matnr = mseg~matnr AND mara~mtart = 'ROH'
WHERE mkpf~budat GE gv_po_date_low AND mkpf~budat LE gv_po_date_high
AND mseg~bwart = '261'
AND mseg~matnr IN s_matnr
AND mseg~werks = p_werks.
CLEAR: wa_mseg.
LOOP AT gt_mseg INTO wa_mseg.
wa_mseg-month = wa_mseg-budat+4(2).
wa_mseg-year = wa_mseg-budat+0(4).
MODIFY gt_mseg FROM wa_mseg TRANSPORTING month year.
ENDLOOP.
SORT gt_mseg BY matnr year month .
CLEAR: wa_mseg, lv_menge.
LOOP AT gt_mseg INTO wa_mseg.
lv_menge = lv_menge + wa_mseg-menge.
CLEAR: lv_year, lv_matnr.
lv_year = wa_mseg-year.
lv_matnr = wa_mseg-matnr.
AT END OF month.
CLEAR: wa_261.
MOVE-CORRESPONDING wa_mseg TO wa_261.
wa_261-year = lv_year.
wa_261-menge = lv_menge.
wa_261-matnr = lv_matnr.
APPEND wa_261 TO gt_261.
CLEAR: wa_mseg, lv_menge, lv_year, lv_matnr.
ENDAT.
ENDLOOP.
SORT gt_out BY lifnr matnr.
CLEAR: wa_out, lv_kbetr.
LOOP AT gt_out INTO wa_out.
wa_out-month = wa_out-budat+4(2).
wa_out-year = wa_out-budat+0(4).
READ TABLE gt_price INTO wa_price WITH KEY knumv = wa_out-knumv.
IF sy-subrc IS INITIAL.
wa_out-kbetr = wa_price-kbetr.
ENDIF.
CLEAR: lv_ktx.
SELECT SINGLE ktx INTO lv_ktx FROM t247
WHERE spras = sy-langu
AND mnr = wa_out-budat+4(2).
wa_out-price = lv_ktx.
CONCATENATE lv_ktx wa_out-year '_' 'PRICE' INTO wa_out-price.
CLEAR: wa_output.
MOVE-CORRESPONDING wa_out TO wa_output.
APPEND wa_output TO gt_output.
CLEAR wa_output.
ENDLOOP.
LOOP AT gt_261 INTO wa_261.
wa_output-year = wa_261-year.
wa_output-month = wa_261-month.
wa_output-matnr = wa_261-matnr.
wa_output-tot_consum = wa_261-menge.
APPEND wa_output TO gt_output.
CLEAR wa_output.
ENDLOOP.
CLEAR: wa_fieldcat.
LOOP AT gt_fieldcat INTO wa_fieldcat.
CLEAR: wa_field.
MOVE-CORRESPONDING wa_fieldcat TO wa_field.
APPEND wa_field TO gt_field.
ENDLOOP.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gt_field
IMPORTING
ep_table = lt_dyntab.
ASSIGN lt_dyntab->* TO <gfs_table>.
CREATE DATA lwa_dyntab LIKE LINE OF <gfs_table>.
ASSIGN lwa_dyntab->* TO <lfs_wa>.
SORT gt_output BY mblnr budat ASCENDING.
* .
APPEND LINES OF gt_output TO gt_output1.
CLEAR: wa_output.
LOOP AT gt_output INTO wa_output.
CLEAR: wa_fieldcat.
ASSIGN COMPONENT 'MATNR' OF STRUCTURE <lfs_wa> TO <lfs_fld>.
IF sy-subrc IS INITIAL.
<lfs_fld> = wa_output-matnr.
ENDIF.
ASSIGN COMPONENT 'MAKTX' OF STRUCTURE <lfs_wa> TO <lfs_fld>.
IF sy-subrc IS INITIAL.
<lfs_fld> = wa_output-maktx.
ENDIF.
ASSIGN COMPONENT 'LIFNR' OF STRUCTURE <lfs_wa> TO <lfs_fld>.
IF sy-subrc IS INITIAL.
<lfs_fld> = wa_output-lifnr.
ENDIF.
ASSIGN COMPONENT 'NAME1' OF STRUCTURE <lfs_wa> TO <lfs_fld>.
IF sy-subrc IS INITIAL.
<lfs_fld> = wa_output-name1.
ENDIF.
CLEAR: wa_output1.
LOOP AT gt_field INTO wa_field WHERE fieldname NE 'MATNR' AND fieldname NE 'MAKTX' AND fieldname NE 'LIFNR' AND fieldname NE 'NAME1'.
ASSIGN COMPONENT wa_field-fieldname OF STRUCTURE <lfs_wa> TO <lfs_fld>.
IF sy-subrc IS INITIAL.
READ TABLE gt_output1 INTO wa_output1 WITH KEY matnr = wa_output-matnr lifnr = wa_output-lifnr price = wa_field-fieldname.
IF sy-subrc IS INITIAL.
DELETE gt_output1 INDEX sy-tabix.
<lfs_fld> = wa_output1-kbetr.
lv_pur_qty = wa_output1-price.
REPLACE FIRST OCCURRENCE OF 'PRICE' IN lv_pur_qty WITH 'PUR_QTY'.
ASSIGN COMPONENT lv_pur_qty OF STRUCTURE <lfs_wa> TO <lfs_fld>.
IF sy-subrc IS INITIAL.
<lfs_fld> = wa_output1-menge.
ENDIF.
ENDIF.
ELSEIF sy-subrc IS NOT INITIAL.
EXIT.
ENDIF.
ENDLOOP.
APPEND <lfs_wa> TO <gfs_table>.
CLEAR: <lfs_wa>.
ENDLOOP.
*Delete entries with empty dynamic field value
LOOP AT <gfs_table> ASSIGNING <lfs_wa>.
lv_tabix = sy-tabix.
lv_index = 5.
DO .
lv_delete = 'X'.
ASSIGN COMPONENT lv_index OF STRUCTURE <lfs_wa> TO <lfs_fld>.
IF sy-subrc IS INITIAL.
IF <lfs_fld> IS NOT INITIAL.
lv_delete = ''.
EXIT.
ENDIF.
ELSEIF sy-subrc IS NOT INITIAL.
EXIT.
ENDIF.
lv_index = lv_index + 1.
ENDDO.
IF lv_delete = 'X'.
DELETE <gfs_table> INDEX lv_tabix.
ENDIF.
ENDLOOP.
gt_output1[] = gt_output[].
DELETE gt_output1 WHERE tot_consum = '0.000'.
SORT gt_output1 BY matnr price tot_consum.
DELETE ADJACENT DUPLICATES FROM gt_output1 COMPARING matnr price tot_consum.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gt_field
IMPORTING
ep_table = lt_dyntab1.
ASSIGN lt_dyntab1->* TO <gfs_table1>.
CREATE DATA lwa_dyntab1 LIKE LINE OF <gfs_table1>.
ASSIGN lwa_dyntab1->* TO <lfs_wa1>.
CLEAR: wa_output1, wa_matnr.
LOOP AT gt_output1 INTO wa_output1.
wa_matnr-matnr = wa_output1-matnr.
APPEND wa_matnr TO gt_matnr.
ENDLOOP.
SORT gt_matnr BY matnr.
DELETE ADJACENT DUPLICATES FROM gt_matnr COMPARING matnr.
CLEAR: wa_matnr.
LOOP AT gt_matnr INTO wa_matnr.
LOOP AT gt_output1 INTO wa_output1 WHERE matnr = wa_matnr-matnr.
ASSIGN COMPONENT 'MATNR' OF STRUCTURE <lfs_wa1> TO <lfs_matnr>.
lv_pur_qty = wa_output1-price.
CLEAR: lv_ktx.
SELECT SINGLE ktx INTO lv_ktx FROM t247
WHERE spras = sy-langu
AND mnr = wa_output1-month.
CONCATENATE lv_ktx wa_output1-year '_' 'TOT_CONSUM' INTO lv_pur_qty.
ASSIGN COMPONENT lv_pur_qty OF STRUCTURE <lfs_wa1> TO <lfs_tot>.
IF sy-subrc IS INITIAL.
READ TABLE gt_output1 INTO wa_output2 WITH KEY matnr = wa_output1-matnr.
IF sy-subrc IS INITIAL.
ASSIGN COMPONENT 'MAKTX' OF STRUCTURE <lfs_wa1> TO <lfs_maktx>.
ASSIGN COMPONENT 'LIFNR' OF STRUCTURE <lfs_wa1> TO <lfs_lifnr>.
ASSIGN COMPONENT 'NAME1' OF STRUCTURE <lfs_wa1> TO <lfs_name1>.
IF lv_no_star = ''.
<lfs_maktx> = '*'.
<lfs_lifnr> = '*'.
ELSEIF lv_no_star = 'X'.
<lfs_maktx> = wa_output1-maktx.
<lfs_lifnr> = wa_output1-lifnr.
ENDIF.
<lfs_matnr> = wa_output1-matnr.
<lfs_tot> = wa_output1-tot_consum.
ENDIF.
ELSEIF sy-subrc IS NOT INITIAL.
EXIT.
ENDIF.
ENDLOOP.
APPEND <lfs_wa1> TO <gfs_table1>.
CLEAR: <lfs_wa1>.
ENDLOOP.
APPEND LINES OF <gfs_table1> TO <gfs_table>.
ENDFORM. " GET_DATA
Input Screen :
Output Screen :