Skip to Content
author's profile photo Former Member
Former Member

Problem with OBD number

Hi,

I have created STO for FNV document type,for this document type after creating STO,automatically OBD will be created and tis OBD number will save in LIPS table.Now my problem is,i am writing select query for getting OBD numbers for STO's and display ALV.While displaying ALV for some STO's ODB number is not displaying,but in LIPS those STO's having OBD Numbers.Kindly tell me where i did went wrong.

Thanks

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Dec 11, 2013 at 05:39 AM

    Hi Sai,

    is it the problem of extracting data, can you copy the code here!

    it is very simple,

    extract the STO from EKKO and EKPO INTO ITAB_STO_PO where BSART = 'STO DOCUMENT TYPE'.

    extract the VBELN PSONR INTO ITAB_STO_DL FROM LIPS FOR ALL ENTRIES IN ITAB_STO_PO

    WHERE VGBEL = ITAB_STO_PO-EBELN AND

    VGPOS = ITAB_STO_PO-EBELP.

    *

    will suggest you!

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Kiran,

      I have developed Upload program for uploading quantity for FNV document type for different sites,For this i have used BAPI_PO_CREATE1 function module for creating STO for site wise,once STO will be created for this STO,OBD will be created automatically.Now my problem is while executing complete program,may be OBD numbers are creating late or some other reason,but in LIPS table OBD numbers are displaying,in my final ALV display OBD numbers are not displaying.Here is my complete code.

      *&---------------------------------------------------------------------*
      *& Report ZSTOTEST
      *&
      *&---------------------------------------------------------------------*
      *&
      *&
      *&---------------------------------------------------------------------*

      REPORT zbdc_sto_upload.


      TYPE-POOLS:slis,truxs.

      TYPES: BEGIN OF ty_output,
      article TYPE marc-matnr,
      site TYPE marc-werks,
      quantity TYPE ekpo-menge,
      END OF ty_output.

      TYPES: BEGIN OF ty_output2,
      site TYPE marc-werks,
      article TYPE marc-matnr,
      quantity TYPE ekpo-menge,
      END OF ty_output2.

      DATA:it_output_w TYPE STANDARD TABLE OF ty_output2,
      wa_output_w TYPE ty_output2.

      DATA: it_output TYPE TABLE OF ty_output,
      wa_output TYPE ty_output,
      wa_output2 TYPE ty_output.

      TYPES:BEGIN OF ty_mard,
      werks TYPE mard-werks,
      matnr TYPE mard-matnr,
      lgort TYPE mard-lgort,
      labst TYPE mard-labst,
      END OF ty_mard.

      DATA:it_mard TYPE STANDARD TABLE OF ty_mard,
      wa_mard TYPE ty_mard.

      TYPES:BEGIN OF ty_po,
      werks TYPE mard-werks,
      po TYPE ekko-ebeln,
      END OF ty_po.

      DATA:it_po TYPE STANDARD TABLE OF ty_po,
      wa_po TYPE ty_po.

      TYPES:BEGIN OF ty_vbbe,
      matnr TYPE vbbe-matnr,
      vbeln TYPE vbbe-vbeln,
      werks TYPE vbbe-werks,
      lgort TYPE vbbe-lgort,
      omeng TYPE vbbe-omeng,
      END OF ty_vbbe.

      DATA:it_vbbe TYPE STANDARD TABLE OF ty_vbbe,
      it_vbbe2 TYPE STANDARD TABLE OF ty_vbbe,
      wa_vbbe TYPE ty_vbbe,
      wa_vbbe2 TYPE ty_vbbe..

      TYPES:BEGIN OF ty_zstoredc,
      store TYPE zstoredc-store,
      END OF ty_zstoredc.

      DATA:it_zstoredc TYPE STANDARD TABLE OF ty_zstoredc,
      wa_zstoredc TYPE ty_zstoredc.

      *TYPES:BEGIN OF ty_t001w,
      * werks TYPE t001w-werks,
      * END OF ty_t001w.
      *
      *DATA:it_t001w TYPE STANDARD TABLE OF ty_t001w,
      * wa_t001w TYPE ty_t001w.

      DATA:w_bwkey TYPE t001w-bwkey.
      DATA:werks_final TYPE t001w-werks.

      """""""""""""""""""""""""""""""""""""""""" For listed articles
      TYPES:BEGIN OF ty_list,
      matnr TYPE marc-matnr,
      werks TYPE marc-werks,
      dc TYPE marc-werks,
      END OF ty_list.

      DATA:it_list TYPE STANDARD TABLE OF ty_list,
      wa_list TYPE ty_list,
      it_list2 TYPE STANDARD TABLE OF ty_list,
      wa_list2 TYPE ty_list.


      TYPES:BEGIN OF ty_free,
      matnr TYPE marc-matnr,
      werks TYPE marc-werks,
      qnty TYPE ekpo-menge,
      free_stock TYPE ekpo-menge,
      END OF ty_free.

      DATA:it_free TYPE STANDARD TABLE OF ty_free,
      wa_free TYPE ty_free.

      TYPES:BEGIN OF ty_lips,
      vbeln TYPE lips-vbeln,
      matnr TYPE lips-matnr,
      vgbel TYPE lips-vgbel,
      lfimg TYPE lips-lfimg,
      END OF ty_lips.

      DATA:it_lips TYPE STANDARD TABLE OF ty_lips,
      wa_lips TYPE ty_lips.


      TYPES:BEGIN OF ty_lips2,
      vbeln TYPE lips-vbeln,
      vgbel TYPE lips-vgbel,
      lfimg TYPE lips-lfimg,
      END OF ty_lips2.
      DATA:wa_lips2 TYPE ty_lips2,
      it_lips2 TYPE STANDARD TABLE OF ty_lips2.

      DATA:vbeln_l TYPE lips-vbeln,
      sto_l TYPE lips-vgbel.

      TYPES:BEGIN OF ty_final,
      po_num TYPE ekko-ebeln,
      vbeln TYPE lips-vbeln,
      werks TYPE marc-werks,
      qnty_final TYPE ekpo-menge,
      deliver_qnty TYPE lips-lfimg,
      END OF ty_final.

      DATA:it_final TYPE STANDARD TABLE OF ty_final,
      wa_final TYPE ty_final.

      TYPES:BEGIN OF ty_site,
      dc TYPE marc-werks,
      site TYPE marc-werks,
      END OF ty_site.

      DATA: it_site TYPE STANDARD TABLE OF ty_site,
      wa_site TYPE ty_site.

      DATA: it_raw TYPE truxs_t_text_data.


      DATA: it_fcat_list TYPE slis_t_fieldcat_alv,
      wa_fcat_list TYPE slis_fieldcat_alv.

      DATA: it_fcat_free TYPE slis_t_fieldcat_alv,
      wa_fcat_free TYPE slis_fieldcat_alv.

      DATA: it_fcat_site TYPE slis_t_fieldcat_alv,
      wa_fcat_site TYPE slis_fieldcat_alv.

      DATA:it_sort TYPE slis_t_sortinfo_alv,
      wa_sort TYPE slis_sortinfo_alv.

      DATA:it_sort_free TYPE slis_t_sortinfo_alv,
      wa_sort_free TYPE slis_sortinfo_alv.

      DATA:it_sort_site TYPE slis_t_sortinfo_alv,
      wa_sort_site TYPE slis_sortinfo_alv.


      DATA : header LIKE bapimepoheader ,
      headerx LIKE bapimepoheaderx .

      DATA : item LIKE bapimepoitem OCCURS 0 WITH HEADER LINE,
      itemx LIKE bapimepoitemx OCCURS 0 WITH HEADER LINE,

      return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

      CONSTANTS : c_x VALUE 'X'.

      DATA: v_exppurchaseorder LIKE bapimepoheader-po_number.
      DATA : w_num TYPE ekpo-ebelp.

      DATA store_name TYPE zstoredc-store.

      DATA : gd_scol TYPE i VALUE '1',
      gd_srow TYPE i VALUE '1',
      gd_ecol TYPE i VALUE '256',
      gd_erow TYPE i VALUE '65536'.


      SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
      PARAMETERS:p_site TYPE marc-werks OBLIGATORY.
      PARAMETERS:p_file TYPE rlgrap-filename OBLIGATORY.
      SELECTION-SCREEN END OF BLOCK b1.

      AT SELECTION-SCREEN.
      SELECT SINGLE bwkey FROM t001w INTO w_bwkey WHERE bwkey = p_site
      AND vlfkz = 'B'.
      IF w_bwkey IS INITIAL.
      MESSAGE s000(8z) WITH 'Please enter correct suppying site' DISPLAY LIKE 'E'.
      STOP.
      ENDIF.


      AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      PERFORM get_file.

      START-OF-SELECTION.


      PERFORM upload_excel_file USING p_file
      gd_scol
      gd_srow
      gd_ecol
      gd_erow.

      PERFORM get_data.

      *&---------------------------------------------------------------------*
      *& Form GET_FILE
      *&---------------------------------------------------------------------*
      * text
      *----------------------------------------------------------------------*
      * --> p1 text
      * <-- p2 text
      *----------------------------------------------------------------------*
      FORM get_file .

      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
      EXPORTING
      program_name = syst-repid
      dynpro_number = syst-dynnr
      field_name = p_file
      CHANGING
      file_name = p_file.
      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. " GET_FILE
      *&---------------------------------------------------------------------*
      *& Form UPLOAD_EXCEL_FILE
      *&---------------------------------------------------------------------*
      * text
      *----------------------------------------------------------------------*
      * -->P_IT_OUTPUT text
      * -->P_P_FILE text
      * -->P_GD_SCOL text
      * -->P_GD_SROW text
      * -->P_GD_ECOL text
      * -->P_GD_EROW text
      *----------------------------------------------------------------------*
      FORM upload_excel_file USING p_p_file
      p_gd_scol
      p_gd_srow
      p_gd_ecol
      p_gd_erow.

      DATA : lt_intern TYPE kcde_cells OCCURS 0 WITH HEADER LINE
      .
      DATA:it_excel_tab TYPE STANDARD TABLE OF alsmex_tabline,
      wa_excel_tab TYPE alsmex_tabline,
      wa_excel_tab2 TYPE alsmex_tabline.

      DATA : ld_index TYPE i,
      l TYPE i,
      total TYPE i.

      DATA:it_fcat TYPE lvc_t_fcat,
      wa_fcat TYPE lvc_s_fcat.
      DATA:matnr TYPE marc-matnr.

      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
      filename = p_file
      i_begin_col = p_gd_scol
      i_begin_row = p_gd_srow
      i_end_col = p_gd_ecol
      i_end_row = p_gd_erow
      TABLES
      intern = it_excel_tab
      * EXCEPTIONS
      * INCONSISTENT_PARAMETERS = 1
      * UPLOAD_OLE = 2
      * OTHERS = 3
      .
      IF sy-subrc <> 0.
      * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
      * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.


      IF it_excel_tab IS INITIAL.
      MESSAGE e001(00) WITH 'No Data Uploaded'.
      STOP.
      ELSE.

      """""""""""""""""""""""""""""""
      SORT it_excel_tab BY row DESCENDING.
      READ TABLE it_excel_tab INTO wa_excel_tab INDEX 1.

      SORT it_excel_tab BY col DESCENDING.
      READ TABLE it_excel_tab INTO wa_excel_tab2 INDEX 1.

      total = wa_excel_tab-row * wa_excel_tab2-col.
      DESCRIBE TABLE it_excel_tab LINES l.

      IF total NE l.
      MESSAGE s000(8z) WITH 'Empty values are there please check it' DISPLAY LIKE 'E'.
      STOP.
      ENDIF.

      """"""""""""""""""""""""""""""

      TRANSLATE p_site TO UPPER CASE.
      IF p_site CS 'HW'.
      store_name = 'HY%'.
      ELSEIF p_site CS 'BW'.
      store_name = 'BL%'.
      ELSEIF p_site CS 'CW'.
      store_name = 'CH%'.
      ENDIF.

      SELECT
      store
      FROM zstoredc
      INTO TABLE
      it_zstoredc
      WHERE store LIKE store_name.

      SORT it_excel_tab BY row col.
      """"""""""""""""""""""""""""""""""""""""""""""


      LOOP AT it_excel_tab INTO wa_excel_tab WHERE row = 1 AND col GT 2.

      TRANSLATE wa_excel_tab-value TO UPPER CASE.
      READ TABLE it_zstoredc INTO wa_zstoredc WITH KEY store = wa_excel_tab-value.
      IF sy-subrc NE 0.
      wa_site-dc = p_site.
      wa_site-site = wa_excel_tab-value.
      APPEND wa_site TO it_site.
      * MESSAGE e001(00) WITH 'Please enter correct site'.
      * EXIT.
      ENDIF.
      ENDLOOP.

      IF it_site IS NOT INITIAL.
      PERFORM site_fieldcat.
      MESSAGE s000(8z) WITH text-014 DISPLAY LIKE 'E'.
      PERFORM alv_display_site.
      * EXIT.
      STOP.
      ENDIF.

      LOOP AT it_excel_tab INTO wa_excel_tab WHERE row NE 1.
      IF wa_excel_tab-col EQ 1.

      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
      input = wa_excel_tab-value
      IMPORTING
      output = matnr.
      ENDIF.
      IF wa_excel_tab-col GT 2.
      READ TABLE it_excel_tab INTO wa_excel_tab2 WITH KEY row = 1
      col = wa_excel_tab-col.

      IF sy-subrc = 0.
      TRANSLATE wa_excel_tab2-value TO UPPER CASE.

      READ TABLE it_output INTO wa_output2 WITH KEY article = matnr
      site = wa_excel_tab2-value.
      IF sy-subrc = 0.
      MESSAGE s000(8z) WITH 'Site or Article Repetitions are not allowed' DISPLAY LIKE 'E'.
      STOP.
      ENDIF.
      wa_output-site = wa_excel_tab2-value.
      wa_output-article = matnr .
      wa_output-quantity = wa_excel_tab-value.
      APPEND wa_output TO it_output.

      ENDIF.
      ENDIF.
      ENDLOOP.
      ENDIF.

      ENDFORM. " UPLOAD_EXCEL_FILE
      *&---------------------------------------------------------------------*
      *& Form GET_DATA
      *&---------------------------------------------------------------------*
      * text
      *----------------------------------------------------------------------*
      * --> p1 text
      * <-- p2 text
      *----------------------------------------------------------------------*
      FORM get_data .
      IF it_output IS INITIAL.
      MESSAGE e001(00) WITH 'Please check the upload file'.
      EXIT.
      ENDIF.

      SORT it_output BY article site .
      DELETE ADJACENT DUPLICATES FROM it_output COMPARING article site.
      DELETE it_output WHERE quantity EQ 0.
      *
      TYPES:BEGIN OF ty_wlk1,
      filia TYPE wlk1-filia,
      artnr TYPE wlk1-artnr,
      datbi TYPE wlk1-datbi,
      datab TYPE wlk1-datab,
      END OF ty_wlk1.

      DATA:it_wlk1 TYPE STANDARD TABLE OF ty_wlk1,
      wa_wlk1 TYPE ty_wlk1.
      *
      SELECT filia
      artnr
      FROM wlk1
      INTO TABLE it_wlk1
      FOR ALL ENTRIES IN it_output
      WHERE artnr = it_output-article
      AND datbi = '99991231'
      AND datab LE sy-datum.


      SORT it_output BY site article .
      LOOP AT it_output INTO wa_output.
      TRANSLATE p_site TO UPPER CASE.
      READ TABLE it_wlk1 INTO wa_wlk1 WITH KEY filia = p_site
      artnr = wa_output-article.
      IF sy-subrc NE 0.
      wa_list2-matnr = wa_output-article. " For FNV checking
      wa_list2-werks = wa_output-site.
      wa_list2-dc = p_site.

      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
      EXPORTING
      input = wa_list2-matnr
      IMPORTING
      output = wa_list2-matnr.

      APPEND wa_list2 TO it_list2.
      ENDIF.

      TRANSLATE wa_output-site TO UPPER CASE.
      READ TABLE it_wlk1 INTO wa_wlk1 WITH KEY filia = wa_output-site
      artnr = wa_output-article.
      IF sy-subrc NE 0.
      wa_list-matnr = wa_output-article. " For Listing
      wa_list-werks = wa_output-site.
      wa_list-dc = p_site.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
      EXPORTING
      input = wa_list-matnr
      IMPORTING
      output = wa_list-matnr.
      APPEND wa_list TO it_list. " For Listing
      * MESSAGE E001(00) WITH 'Article is not listed properly'.
      * EXIT.
      ENDIF.
      ENDLOOP.

      IF it_list IS NOT INITIAL.
      PERFORM list_fieldcat.
      MESSAGE s000(8z) WITH text-012 DISPLAY LIKE 'E'.
      PERFORM list_alv_display.
      STOP.
      ENDIF.

      IF it_list2 IS NOT INITIAL.

      REFRESH it_list.
      it_list = it_list2.

      PERFORM list_fieldcat.
      MESSAGE s000(8z) WITH text-013 DISPLAY LIKE 'E'.
      PERFORM list_alv_display.
      STOP.
      ENDIF.

      SELECT werks
      matnr
      lgort
      labst
      FROM mard
      INTO TABLE it_mard
      FOR ALL ENTRIES IN it_output
      WHERE werks = p_site
      AND matnr = it_output-article
      AND lgort = 'SL01'.


      SELECT matnr
      vbeln
      werks
      lgort
      omeng
      FROM vbbe
      INTO TABLE it_vbbe
      FOR ALL ENTRIES IN it_output
      WHERE matnr = it_output-article
      AND werks = p_site
      AND lgort = 'SL01'.

      SORT it_vbbe BY matnr.

      DATA:matnr1 TYPE vbbe-matnr,
      werks1 TYPE vbbe-werks,
      lgort1 TYPE vbbe-lgort.

      LOOP AT it_vbbe INTO wa_vbbe.
      matnr1 = wa_vbbe-matnr.
      werks1 = wa_vbbe-werks.
      lgort1 = wa_vbbe-lgort.
      AT END OF matnr.
      SUM.
      wa_vbbe-matnr = matnr1.
      wa_vbbe-werks = werks1.
      wa_vbbe-lgort = lgort1.
      APPEND wa_vbbe TO it_vbbe2.
      ENDAT.
      ENDLOOP.
      REFRESH it_vbbe.
      it_vbbe = it_vbbe2.


      DATA:free_stock TYPE mard-labst.
      DATA:matnr2 TYPE marc-matnr,
      werks2 TYPE marc-werks,
      quantity2 TYPE ekpo-menge.

      DATA:it_output2 TYPE STANDARD TABLE OF ty_output,
      wa_output2 TYPE ty_output.


      SORT it_output BY article site.
      LOOP AT it_output INTO wa_output.
      matnr2 = wa_output-article.
      * werks2 = wa_output-site.
      * quantity2 = wa_output-quantity.
      AT END OF article.
      SUM.
      wa_output-article = matnr2.
      * wa_output-site = werks2.
      APPEND wa_output TO it_output2.
      ENDAT.
      ENDLOOP.

      LOOP AT it_output2 INTO wa_output2.
      READ TABLE it_mard INTO wa_mard WITH KEY matnr = wa_output2-article
      werks = p_site.
      IF sy-subrc NE 0.
      wa_mard-labst = 0.
      ENDIF.
      READ TABLE it_vbbe INTO wa_vbbe WITH KEY matnr = wa_output2-article
      werks = p_site.
      IF sy-subrc NE 0.
      wa_vbbe-omeng = 0.
      ENDIF.
      free_stock = wa_mard-labst - wa_vbbe-omeng.
      *
      IF wa_output2-quantity GT free_stock.
      wa_free-matnr = wa_output2-article. " Free Stock
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
      EXPORTING
      input = wa_free-matnr
      IMPORTING
      output = wa_free-matnr.
      wa_free-werks = p_site.
      wa_free-qnty = wa_output2-quantity.
      wa_free-free_stock = free_stock.
      APPEND wa_free TO it_free. " Free Stock
      * MESSAGE e001(00) WITH 'EAN Quantity is not available'.
      * EXIT.
      ENDIF.
      ENDLOOP.


      IF it_free IS NOT INITIAL.
      PERFORM fieldcat_free.
      PERFORM alv_display_free.
      * MESSAGE e001(00) WITH 'EAN Quantity is not available'.
      STOP.
      ENDIF.

      """"""""""""""""""""""""""""""""""""
      LOOP AT it_output INTO wa_output.
      TRANSLATE wa_output-site TO UPPER CASE.
      wa_output_w-site = wa_output-site.
      wa_output_w-article = wa_output-article.
      wa_output_w-quantity = wa_output-quantity.
      APPEND wa_output_w TO it_output_w.
      ENDLOOP.

      SORT it_output_w BY site article.


      LOOP AT it_output_w INTO wa_output_w.
      w_num = w_num +'00010'.

      header-comp_code = '2000' .
      header-doc_type = 'ZFVS' .
      header-creat_date = sy-datum .
      header-vendor = p_site .
      * header-SUPPL_PLNT = wa_output_w-site.
      header-langu = sy-langu .
      header-purch_org = '2000' .
      header-pur_group = 'FD' .

      headerx-comp_code = c_x.
      headerx-doc_type = c_x.
      headerx-creat_date = c_x.
      headerx-vendor = c_x.
      headerx-langu = c_x.
      headerx-purch_org = c_x.
      headerx-pur_group = c_x.

      item-po_item = w_num.
      item-material = wa_output_w-article.
      item-ematerial = wa_output_w-article.
      item-plant = wa_output_w-site.
      * item-stge_loc = 'SL01'.
      item-quantity = wa_output_w-quantity.
      APPEND item.

      itemx-po_item = w_num.
      itemx-material = c_x.
      itemx-plant = c_x .
      itemx-quantity = c_x .
      APPEND itemx.

      AT END OF site.
      CALL FUNCTION 'BAPI_PO_CREATE1'
      EXPORTING
      poheader = header
      poheaderx = headerx
      IMPORTING
      exppurchaseorder = v_exppurchaseorder
      TABLES
      return = return
      poitem = item
      poitemx = itemx.


      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
      wait = 'X'.

      IF v_exppurchaseorder IS NOT INITIAL.
      wa_po-po = v_exppurchaseorder.
      wa_po-werks = wa_output_w-site.
      APPEND wa_po TO it_po.
      ENDIF.

      REFRESH item.
      REFRESH itemx.
      REFRESH return.
      CLEAR: w_num.

      ENDAT.
      ENDLOOP.
      """"""""""""""""""""""""""""""""""""""
      IF it_po IS NOT INITIAL.
      SELECT vbeln
      matnr
      vgbel
      lfimg
      FROM lips
      INTO TABLE it_lips
      FOR ALL ENTRIES IN it_po
      WHERE vgbel = it_po-po.
      ENDIF.



      SORT it_lips BY vbeln.
      LOOP AT it_lips INTO wa_lips.

      sto_l = wa_lips-vgbel.
      AT END OF vbeln.
      vbeln_l = wa_lips-vbeln.

      SUM.
      wa_lips2-vbeln = vbeln_l.
      wa_lips2-vgbel = sto_l.
      wa_lips2-lfimg = wa_lips-lfimg.
      APPEND wa_lips2 TO it_lips2.
      ENDAT.
      ENDLOOP.



      SORT it_output_w BY site.
      LOOP AT it_output_w INTO wa_output_w.
      * AT NEW site.

      AT END OF site.
      werks_final = wa_output_w-site.
      SUM.
      wa_output_w-site = werks_final .
      READ TABLE it_po INTO wa_po WITH KEY werks = wa_output_w-site.
      IF sy-subrc = 0." AND wa_po-po IS NOT INITIAL.
      wa_final-po_num = wa_po-po.
      wa_final-werks = wa_po-werks.
      wa_final-qnty_final = wa_output_w-quantity.
      READ TABLE it_lips2 INTO wa_lips2 WITH KEY vgbel = wa_po-po.
      IF sy-subrc = 0.
      wa_final-deliver_qnty = wa_lips2-lfimg.
      * wa_final-vbeln = wa_lips-vbeln.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
      EXPORTING
      input = wa_lips2-vbeln
      IMPORTING
      output = wa_final-vbeln.
      ENDIF.

      APPEND wa_final TO it_final.
      CLEAR:wa_final.
      ENDIF.
      ENDAT.
      ENDLOOP.

      SORT it_final BY po_num.
      IF it_final IS INITIAL.
      MESSAGE e001(00) WITH 'No STOs are created'.
      STOP.
      ENDIF.


      DATA: it_fcat TYPE slis_t_fieldcat_alv,
      wa_fcat TYPE slis_fieldcat_alv.

      DATA:it_sort TYPE slis_t_sortinfo_alv,
      wa_sort TYPE slis_sortinfo_alv,
      wa_layout TYPE slis_layout_alv.

      wa_fcat-fieldname = 'PO_NUM'.
      wa_fcat-col_pos = '1'.
      wa_fcat-seltext_l = 'STO Number'.
      wa_fcat-tabname = 'IT_FINAL'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.

      wa_fcat-fieldname = 'VBELN'.
      wa_fcat-col_pos = '2'.
      wa_fcat-seltext_l = 'OBD Number'.
      wa_fcat-tabname = 'IT_FINAL'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.


      wa_fcat-fieldname = 'WERKS'.
      wa_fcat-col_pos = '3'.
      wa_fcat-seltext_l = 'Site'.
      wa_fcat-tabname = 'IT_FINAL'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.

      wa_fcat-fieldname = 'QNTY_FINAL'.
      wa_fcat-col_pos = '4'.
      wa_fcat-seltext_l = 'Uploaded Qnty'.
      wa_fcat-tabname = 'IT_FINAL'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.

      wa_fcat-fieldname = 'DELIVER_QNTY'.
      wa_fcat-col_pos = '5'.
      wa_fcat-seltext_l = 'Required Qnty'.
      wa_fcat-tabname = 'IT_FINAL'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.


      CLEAR wa_layout.
      wa_layout-colwidth_optimize = 'X'." Optimization of Col width
      wa_layout-no_totalline = 'X'.

      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
      * I_INTERFACE_CHECK = ' '
      * I_BYPASSING_BUFFER = ' '
      * I_BUFFER_ACTIVE = ' '
      i_callback_program = sy-cprog
      * I_CALLBACK_PF_STATUS_SET = ' '
      * I_CALLBACK_USER_COMMAND = ' '
      * I_CALLBACK_TOP_OF_PAGE = ' '
      * I_CALLBACK_HTML_TOP_OF_PAGE = ' '
      * I_CALLBACK_HTML_END_OF_LIST = ' '
      * I_STRUCTURE_NAME =
      * I_BACKGROUND_ID = ' '
      * I_GRID_TITLE =
      * I_GRID_SETTINGS =
      is_layout = wa_layout
      it_fieldcat = it_fcat
      * IT_EXCLUDING =
      * IT_SPECIAL_GROUPS =
      * it_sort = it_sort
      * IT_FILTER =
      * IS_SEL_HIDE =
      * I_DEFAULT = 'X'
      * I_SAVE = ' '
      * IS_VARIANT =
      * IT_EVENTS =
      * IT_EVENT_EXIT =
      * IS_PRINT =
      * IS_REPREP_ID =
      * I_SCREEN_START_COLUMN = 0
      * I_SCREEN_START_LINE = 0
      * I_SCREEN_END_COLUMN = 0
      * I_SCREEN_END_LINE = 0
      * I_HTML_HEIGHT_TOP = 0
      * I_HTML_HEIGHT_END = 0
      * IT_ALV_GRAPHICS =
      * IT_HYPERLINK =
      * IT_ADD_FIELDCAT =
      * IT_EXCEPT_QINFO =
      * IR_SALV_FULLSCREEN_ADAPTER =
      * IMPORTING
      * E_EXIT_CAUSED_BY_CALLER =
      * ES_EXIT_CAUSED_BY_USER =
      TABLES
      t_outtab = it_final
      * 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. " GET_DATA
      *&---------------------------------------------------------------------*
      *& Form LIST_FIELDCAT
      *&---------------------------------------------------------------------*
      * text
      *----------------------------------------------------------------------*
      * --> p1 text
      * <-- p2 text
      *----------------------------------------------------------------------*
      FORM list_fieldcat .

      wa_fcat_list-fieldname = 'DC'.
      wa_fcat_list-col_pos = '1'.
      wa_fcat_list-seltext_l = 'Supplying Site'.
      wa_fcat_list-tabname = 'IT_LIST'.
      APPEND wa_fcat_list TO it_fcat_list.
      CLEAR wa_fcat_list.



      wa_fcat_list-fieldname = 'WERKS'.
      wa_fcat_list-col_pos = '2'.
      wa_fcat_list-seltext_l = 'Site'.
      wa_fcat_list-tabname = 'IT_LIST'.
      APPEND wa_fcat_list TO it_fcat_list.
      CLEAR wa_fcat_list.


      wa_fcat_list-fieldname = 'MATNR'.
      wa_fcat_list-col_pos = '3'.
      wa_fcat_list-seltext_l = 'Article'.
      wa_fcat_list-tabname = 'IT_LIST'.
      APPEND wa_fcat_list TO it_fcat_list.
      CLEAR wa_fcat_list.



      wa_sort-fieldname = 'DC'.
      wa_sort-tabname = 'IT_LIST'.
      wa_sort-up = 'X'.
      APPEND wa_sort TO it_sort .
      CLEAR wa_sort.


      wa_sort-fieldname = 'WERKS'.
      wa_sort-tabname = 'IT_LIST'.
      wa_sort-up = 'X'.
      APPEND wa_sort TO it_sort .
      CLEAR wa_sort.


      ENDFORM. " LIST_FIELDCAT
      *&---------------------------------------------------------------------*
      *& Form LIST_ALV_DISPLAY
      *&---------------------------------------------------------------------*
      * text
      *----------------------------------------------------------------------*
      * --> p1 text
      * <-- p2 text
      *----------------------------------------------------------------------*
      FORM list_alv_display .
      DATA:wa_layout_list TYPE slis_layout_alv.


      CLEAR wa_layout_list.
      wa_layout_list-colwidth_optimize = 'X'." Optimization of Col width
      wa_layout_list-no_totalline = 'X'.

      * MESSAGE s000(8z) WITH text-012 DISPLAY LIKE 'E'.

      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
      * I_INTERFACE_CHECK = ' '
      * I_BYPASSING_BUFFER = ' '
      * I_BUFFER_ACTIVE = ' '
      i_callback_program = sy-cprog
      * I_CALLBACK_PF_STATUS_SET = ' '
      * I_CALLBACK_USER_COMMAND = ' '
      * I_CALLBACK_TOP_OF_PAGE = ' '
      * I_CALLBACK_HTML_TOP_OF_PAGE = ' '
      * I_CALLBACK_HTML_END_OF_LIST = ' '
      * I_STRUCTURE_NAME =
      * I_BACKGROUND_ID = ' '
      * I_GRID_TITLE =
      * I_GRID_SETTINGS =
      is_layout = wa_layout_list
      it_fieldcat = it_fcat_list
      * IT_EXCLUDING =
      * IT_SPECIAL_GROUPS =
      it_sort = it_sort
      * IT_FILTER =
      * IS_SEL_HIDE =
      * I_DEFAULT = 'X'
      * I_SAVE = ' '
      * IS_VARIANT =
      * IT_EVENTS =
      * IT_EVENT_EXIT =
      * IS_PRINT =
      * IS_REPREP_ID =
      * I_SCREEN_START_COLUMN = 0
      * I_SCREEN_START_LINE = 0
      * I_SCREEN_END_COLUMN = 0
      * I_SCREEN_END_LINE = 0
      * I_HTML_HEIGHT_TOP = 0
      * I_HTML_HEIGHT_END = 0
      * IT_ALV_GRAPHICS =
      * IT_HYPERLINK =
      * IT_ADD_FIELDCAT =
      * IT_EXCEPT_QINFO =
      * IR_SALV_FULLSCREEN_ADAPTER =
      * IMPORTING
      * E_EXIT_CAUSED_BY_CALLER =
      * ES_EXIT_CAUSED_BY_USER =
      TABLES
      t_outtab = it_list
      * 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. " LIST_ALV_DISPLAY
      *&---------------------------------------------------------------------*
      *& Form FIELDCAT_FREE
      *&---------------------------------------------------------------------*
      * text
      *----------------------------------------------------------------------*
      * --> p1 text
      * <-- p2 text
      *----------------------------------------------------------------------*
      FORM fieldcat_free .


      wa_fcat_free-fieldname = 'WERKS'.
      wa_fcat_free-col_pos = '1'.
      wa_fcat_free-seltext_l = 'Supplying Site'.
      wa_fcat_free-tabname = 'IT_LIST'.
      APPEND wa_fcat_free TO it_fcat_free.
      CLEAR wa_fcat_free.

      wa_fcat_free-fieldname = 'MATNR'.
      wa_fcat_free-col_pos = '2'.
      wa_fcat_free-seltext_l = 'Article'.
      wa_fcat_free-tabname = 'IT_LIST'.
      APPEND wa_fcat_free TO it_fcat_free.
      CLEAR wa_fcat_free.

      wa_fcat_free-fieldname = 'QNTY'.
      wa_fcat_free-col_pos = '3'.
      wa_fcat_free-seltext_l = 'Upload Qnty'.
      wa_fcat_free-tabname = 'IT_LIST'.
      APPEND wa_fcat_free TO it_fcat_free.
      CLEAR wa_fcat_free.

      wa_fcat_free-fieldname = 'FREE_STOCK'.
      wa_fcat_free-col_pos = '4'.
      wa_fcat_free-seltext_l = 'Available Qnty'.
      wa_fcat_free-tabname = 'IT_LIST'.
      APPEND wa_fcat_free TO it_fcat_free.
      CLEAR wa_fcat_free.



      wa_sort_free-fieldname = 'WERKS'.
      wa_sort_free-tabname = 'IT_FREE'.
      wa_sort_free-up = 'X'.
      APPEND wa_sort_free TO it_sort_free .
      CLEAR wa_sort_free.

      ENDFORM. " FIELDCAT_FREE
      *&---------------------------------------------------------------------*
      *& Form ALV_DISPLAY_FREE
      *&---------------------------------------------------------------------*
      * text
      *----------------------------------------------------------------------*
      * --> p1 text
      * <-- p2 text
      *----------------------------------------------------------------------*
      FORM alv_display_free .
      DATA:wa_layout_free TYPE slis_layout_alv.


      CLEAR wa_layout_free.
      wa_layout_free-colwidth_optimize = 'X'." Optimization of Col width
      wa_layout_free-no_totalline = 'X'.
      MESSAGE s000(8z) WITH text-011 DISPLAY LIKE 'E'.

      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
      * I_INTERFACE_CHECK = ' '
      * I_BYPASSING_BUFFER = ' '
      * I_BUFFER_ACTIVE = ' '
      i_callback_program = sy-cprog
      * I_CALLBACK_PF_STATUS_SET = ' '
      * I_CALLBACK_USER_COMMAND = ' '
      * I_CALLBACK_TOP_OF_PAGE = ' '
      * I_CALLBACK_HTML_TOP_OF_PAGE = ' '
      * I_CALLBACK_HTML_END_OF_LIST = ' '
      * I_STRUCTURE_NAME =
      * I_BACKGROUND_ID = ' '
      * I_GRID_TITLE =
      * I_GRID_SETTINGS =
      is_layout = wa_layout_free
      it_fieldcat = it_fcat_free
      * IT_EXCLUDING =
      * IT_SPECIAL_GROUPS =
      it_sort = it_sort_free
      * IT_FILTER =
      * IS_SEL_HIDE =
      * I_DEFAULT = 'X'
      * I_SAVE = ' '
      * IS_VARIANT =
      * IT_EVENTS =
      * IT_EVENT_EXIT =
      * IS_PRINT =
      * IS_REPREP_ID =
      * I_SCREEN_START_COLUMN = 0
      * I_SCREEN_START_LINE = 0
      * I_SCREEN_END_COLUMN = 0
      * I_SCREEN_END_LINE = 0
      * I_HTML_HEIGHT_TOP = 0
      * I_HTML_HEIGHT_END = 0
      * IT_ALV_GRAPHICS =
      * IT_HYPERLINK =
      * IT_ADD_FIELDCAT =
      * IT_EXCEPT_QINFO =
      * IR_SALV_FULLSCREEN_ADAPTER =
      * IMPORTING
      * E_EXIT_CAUSED_BY_CALLER =
      * ES_EXIT_CAUSED_BY_USER =
      TABLES
      t_outtab = it_free
      * 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. " ALV_DISPLAY_FREE
      *&---------------------------------------------------------------------*
      *& Form SITE_FIELDCAT
      *&---------------------------------------------------------------------*
      * text
      *----------------------------------------------------------------------*
      * --> p1 text
      * <-- p2 text
      *----------------------------------------------------------------------*
      FORM site_fieldcat .

      wa_fcat_site-fieldname = 'DC'.
      wa_fcat_site-col_pos = '1'.
      wa_fcat_site-seltext_l = 'Supplying Site'.
      wa_fcat_site-tabname = 'IT_SITE'.
      APPEND wa_fcat_site TO it_fcat_site.
      CLEAR wa_fcat_site.


      wa_fcat_site-fieldname = 'SITE'.
      wa_fcat_site-col_pos = '2'.
      wa_fcat_site-seltext_l = 'Site'.
      wa_fcat_site-tabname = 'IT_LIST'.
      APPEND wa_fcat_site TO it_fcat_site.
      CLEAR wa_fcat_site.

      wa_sort_site-fieldname = 'DC'.
      wa_sort_site-tabname = 'IT_SITE'.
      wa_sort_site-up = 'X'.
      APPEND wa_sort_site TO it_sort_site .
      CLEAR wa_sort_site.

      wa_sort_site-fieldname = 'SITE'.
      wa_sort_site-tabname = 'IT_SITE'.
      wa_sort_site-up = 'X'.
      APPEND wa_sort_site TO it_sort_site .
      CLEAR wa_sort_site.



      ENDFORM. " SITE_FIELDCAT
      *&---------------------------------------------------------------------*
      *& Form ALV_DISPLAY_SITE
      *&---------------------------------------------------------------------*
      * text
      *----------------------------------------------------------------------*
      * --> p1 text
      * <-- p2 text
      *----------------------------------------------------------------------*
      FORM alv_display_site .
      DATA:wa_layout_site TYPE slis_layout_alv.


      CLEAR wa_layout_site.
      wa_layout_site-colwidth_optimize = 'X'." Optimization of Col width
      wa_layout_site-no_totalline = 'X'.

      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
      * I_INTERFACE_CHECK = ' '
      * I_BYPASSING_BUFFER = ' '
      * I_BUFFER_ACTIVE = ' '
      i_callback_program = sy-cprog
      * I_CALLBACK_PF_STATUS_SET = ' '
      * I_CALLBACK_USER_COMMAND = ' '
      * I_CALLBACK_TOP_OF_PAGE = ' '
      * I_CALLBACK_HTML_TOP_OF_PAGE = ' '
      * I_CALLBACK_HTML_END_OF_LIST = ' '
      * I_STRUCTURE_NAME =
      * I_BACKGROUND_ID = ' '
      * I_GRID_TITLE =
      * I_GRID_SETTINGS =
      is_layout = wa_layout_site
      it_fieldcat = it_fcat_site
      * IT_EXCLUDING =
      * IT_SPECIAL_GROUPS =
      it_sort = it_sort_site
      * IT_FILTER =
      * IS_SEL_HIDE =
      * I_DEFAULT = 'X'
      * I_SAVE = ' '
      * IS_VARIANT =
      * IT_EVENTS =
      * IT_EVENT_EXIT =
      * IS_PRINT =
      * IS_REPREP_ID =
      * I_SCREEN_START_COLUMN = 0
      * I_SCREEN_START_LINE = 0
      * I_SCREEN_END_COLUMN = 0
      * I_SCREEN_END_LINE = 0
      * I_HTML_HEIGHT_TOP = 0
      * I_HTML_HEIGHT_END = 0
      * IT_ALV_GRAPHICS =
      * IT_HYPERLINK =
      * IT_ADD_FIELDCAT =
      * IT_EXCEPT_QINFO =
      * IR_SALV_FULLSCREEN_ADAPTER =
      * IMPORTING
      * E_EXIT_CAUSED_BY_CALLER =
      * ES_EXIT_CAUSED_BY_USER =
      TABLES
      t_outtab = it_site
      * 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. " ALV_DISPLAY_SITE

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.