SAP - ABAP : Create Purchase Order With Upload Excel File

 


Custom Structure ZSMM003_1


























Custom Structure ZSMM003_2



Main Program

*&---------------------------------------------------------------------*
*& Report ZMMC003
*&---------------------------------------------------------------------*
*& Program Description  : Upload Purchase Order
*& Created On           : 09.02.2022
*&---------------------------------------------------------------------*
REPORT zmmc003.

INCLUDE zmmc003_01.
INCLUDE zmmc003_02.
INCLUDE zmmc003_03.
INCLUDE zmmc003_04.
INCLUDE zmmc003_05.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.
  CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
      static    'X'
      mask      '*.xls'
    CHANGING
      file_name filename.

AT SELECTION-SCREEN OUTPUT.
  GET PARAMETER ID 'ZFILE' FIELD zz_pid.

  LOOP AT SCREEN.
    IF it_print IS NOT INITIAL AND
      screen-name CS 'P_LINE' OR screen-name CS 'FILENAME').
      screen-input 0.
    ELSE.
      screen-input 1.
    ENDIF.
    MODIFY SCREEN.
  ENDLOOP.

START-OF-SELECTION.
  CALL SCREEN 100.


Include ZMMC003_01

*&---------------------------------------------------------------------*
*& Include          ZMMC003_01
*&---------------------------------------------------------------------*
TYPES:
  BEGIN OF zstab,
    field TYPE char10,
  END OF zstab.

TYPES :
  BEGIN OF ty_print,
    icons  LIKE icon-id,

    ccell  TYPE lvc_t_scol,
    cstyl  TYPE lvc_t_styl,
    cline  TYPE char4,
    matnr  TYPE matnr,
    snote  TYPE char255,
    sebeln TYPE ebeln.
    INCLUDE STRUCTURE zsmm003_2.
TYPES:
  END OF ty_print.
*ZSMM003_2
DATA:
  ob_container TYPE REF TO cl_gui_custom_container,
  ob_grid      TYPE REF TO cl_gui_alv_grid.

DATA:
  it_fieldcat TYPE lvc_t_fcat,
  wa_fieldcat LIKE LINE OF it_fieldcat,
  is_lyout    TYPE lvc_s_layo.

DATA :
 itab TYPE TABLE OF  alsmex_tabline WITH HEADER LINE.

DATA :
  it_excel TYPE TABLE OF zsmm003_1,
  it_print TYPE TABLE OF ty_print,
  it_tprnt TYPE TABLE OF ty_print,
  it_zprnt TYPE TABLE OF ty_print,
  wa_tprnt TYPE ty_print,
  wa_print TYPE ty_print,
  wa_zprnt TYPE ty_print,
  wa_excel TYPE zsmm003_1,
  stab     TYPE TABLE OF zstab.

DATA:
  it_color TYPE TABLE OF lvc_s_scol,
  wa_color TYPE lvc_s_scol,
  vi_color TYPE i.

DATA:
  ex_poheader               LIKE bapimepoheader,
  ex_poheaderx              LIKE bapimepoheaderx,
  ex_poaddrvendor           LIKE bapimepoaddrvendor,
  ex_testrun                LIKE bapiflag-bapiflag,
  ex_memory_uncomplete      LIKE bapiflag-bapiflag,
  ex_memory_complete        LIKE bapiflag-bapiflag,
  ex_poexpimpheader         LIKE bapieikp,
  ex_poexpimpheaderx        LIKE bapieikpx,
  ex_versions               LIKE bapimedcm,
  ex_no_messaging           LIKE bapiflag-bapiflag,
  ex_no_message_req         LIKE bapiflag-bapiflag,
  ex_no_authority           LIKE bapiflag-bapiflag,
  ex_no_price_from_po       LIKE bapiflag-bapiflag,
  ex_park_complete          LIKE bapiflag-bapiflag,
  ex_park_uncomplete        LIKE bapiflag-bapiflag,

  im_exppurchaseorder       LIKE bapimepoheader-po_number,
  im_expheader              LIKE bapimepoheader,
  im_exppoexpimpheader      LIKE bapieikp,

  it_return                 TYPE TABLE OF bapiret2 WITH HEADER LINE,
  it_poitem                 TYPE TABLE OF bapimepoitem,
  wa_poitem                 TYPE bapimepoitem,
  it_poitemx                TYPE TABLE OF bapimepoitemx,
  wa_poitemx                TYPE bapimepoitemx,
  it_poaddrdelivery         TYPE TABLE OF bapimepoaddrdelivery,
  wa_poaddrdelivery         TYPE bapimepoaddrdelivery,
  it_poschedule             TYPE TABLE OF bapimeposchedule,
  wa_poschedule             TYPE bapimeposchedule,
  it_poschedulex            TYPE TABLE OF bapimeposchedulx,
  wa_poschedulex            TYPE bapimeposchedulx,
  it_poaccount              TYPE TABLE OF bapimepoaccount,
  wa_poaccount              TYPE bapimepoaccount,
  it_poaccountprofitsegment TYPE TABLE OF bapimepoaccountprofitsegment,
  wa_poaccountprofitsegment TYPE bapimepoaccountprofitsegment,
  it_poaccountx             TYPE TABLE OF bapimepoaccountx,
  wa_poaccountx             TYPE bapimepoaccountx,
  it_pocondheader           TYPE TABLE OF bapimepocondheader,
  wa_pocondheader           TYPE bapimepocondheader,
  it_pocondheaderx          TYPE TABLE OF bapimepocondheaderx,
  wa_pocondheaderx          TYPE bapimepocondheaderx,
  it_pocond                 TYPE TABLE OF bapimepocond,
  wa_pocond                 TYPE bapimepocond,
  it_pocondx                TYPE TABLE OF bapimepocondx,
  wa_pocondx                TYPE bapimepocondx,
  it_polimits               TYPE TABLE OF bapiesuhc,
  wa_polimits               TYPE bapiesuhc,
  it_pocontractlimits       TYPE TABLE OF bapiesucc,
  wa_pocontractlimits       TYPE bapiesucc,
  it_poservices             TYPE TABLE OF bapiesllc,
  wa_poservices             TYPE bapiesllc,
  it_posrvaccessvalues      TYPE TABLE OF bapiesklc,
  wa_posrvaccessvalues      TYPE bapiesklc,
  it_poservicestext         TYPE TABLE OF bapieslltx,
  wa_poservicestext         TYPE bapieslltx,
  it_extensionin            TYPE TABLE OF bapiparex,
  wa_extensionin            TYPE bapiparex,
  it_extensionout           TYPE TABLE OF bapiparex,
  wa_extensionout           TYPE bapiparex,
  it_poexpimpitem           TYPE TABLE OF bapieipo,
  wa_poexpimpitem           TYPE bapieipo,
  it_poexpimpitemx          TYPE TABLE OF bapieipox,
  wa_poexpimpitemx          TYPE bapieipox,
  it_potextheader           TYPE TABLE OF bapimepotextheader,
  wa_potextheader           TYPE bapimepotextheader,
  it_potextitem             TYPE TABLE OF bapimepotext,
  wa_potextitem             TYPE bapimepotext,
  it_allversions            TYPE TABLE OF bapimedcm_allversions,
  wa_allversions            TYPE bapimedcm_allversions,
  it_popartner              TYPE TABLE OF bapiekkop,
  wa_popartner              TYPE bapiekkop,
  it_pocomponents           TYPE TABLE OF bapimepocomponent,
  wa_pocomponents           TYPE bapimepocomponent,
  it_pocomponentsx          TYPE TABLE OF bapimepocomponentx,
  wa_pocomponentsx          TYPE bapimepocomponentx,
  it_poshipping             TYPE TABLE OF bapiitemship,
  wa_poshipping             TYPE bapiitemship,
  it_poshippingx            TYPE TABLE OF bapiitemshipx,
  wa_poshippingx            TYPE bapiitemshipx,
  it_poshippingexp          TYPE TABLE OF bapimeposhippexp,
  wa_poshippingexp          TYPE bapimeposhippexp,
  it_serialnumber           TYPE TABLE OF bapimeposerialno,
  wa_serialnumber           TYPE bapimeposerialno,
  it_serialnumberx          TYPE TABLE OF bapimeposerialnox,
  wa_serialnumberx          TYPE bapimeposerialnox,
  it_invplanheader          TYPE TABLE OF bapi_invoice_plan_header,
  wa_invplanheader          TYPE bapi_invoice_plan_header,
  it_invplanheaderx         TYPE TABLE OF bapi_invoice_plan_headerx,
  wa_invplanheaderx         TYPE bapi_invoice_plan_headerx,
  it_invplanitem            TYPE TABLE OF bapi_invoice_plan_item,
  wa_invplanitem            TYPE bapi_invoice_plan_item,
  it_invplanitemx           TYPE TABLE OF bapi_invoice_plan_itemx,
  wa_invplanitemx           TYPE bapi_invoice_plan_itemx,
  it_nfmetallitms           TYPE TABLE OF /nfm/bapidocitm WITH HEADER LINE.

DATA:
  zz_pid TYPE char80,
  vc_msg TYPE string,  "String for Message
  vc_str TYPE string,  "String for Popup
  vc_ppp TYPE char4,   "Popup ID
  vc_ans TYPE char1,   "Answer
  vi_tdo TYPE i,       "Timer
  vi_tcn TYPE i,       "Timer Counter
  vi_tot TYPE i,       "Counter Load
  vi_cld TYPE i,       "Counter Load
  vi_row TYPE i,       "Row in Excel for Upload
  vi_err TYPE i,       "Error
  vi_lck TYPE i.       "Lock Table

DATA:
  vi_print TYPE i,
  vi_tmr   TYPE i,             "Timer
  vi_dbl   TYPE i,             "Double
  vi_dec   TYPE i,             "Decimals
  vx_dec   TYPE i,             "Decimals Count
  vc_dec   TYPE t006-andec,    "Decimals UoM
  vc_num   TYPE char15,
  wa_t134  TYPE t134,
  vi_vprsv TYPE vprsv,
  vc_cro   TYPE scal-indicator,
  vc_out   TYPE t006-msehi,    "UoM Out
  vd_dat   TYPE sy-datum,      "Date
  vc_dat   TYPE char10.        "Date in Character

DATA:
  vi_max TYPE i,             "
  vi_cnt TYPE i,             "Counter
  vc_txt TYPE char40,        "Text Output
  vp_prc TYPE p,             "Percent in Decimals
  vc_prc TYPE char3.         "Percent in Character

DATA:
  wa_t006  TYPE t006,          "Units of Measurement
  wa_t006a TYPE t006a,
  wa_tcurc TYPE tcurc,         "Currency Codes
  xx_p_out TYPE DECIMALS 2,  "Output in Decimals
  xx_v_out TYPE char15.

DATA:
  z_ebelp TYPE ebelp,
  z_zekkn TYPE dzekkn,
  z_etenr TYPE etenr,
  z_stunr TYPE stunr.

TABLESt161"Purchasing Document Types
        t001,           "Company Codes
        lfa1,           "Supplier Master (General Section)
        lfm1,           "Vendor master record purchasing organization data
        t024e,          "Purchasing Organizations

        t024,           "Purchasing Groups
        tcurc,          "Currency Codes
        t163k,          "Account Assignment Categories in Purchasing Document
        t163y,          "Texts for Item Categories
        mara,           "General Material Data
        makt,           "Material Descriptions
        marc,           "Plant Data for Material
        ampl,           "Table of Approved Manufacturer Parts
        qinf,           "QM-info record for material and vendor
        t001w,          "Plants/Branches
        t001l,          "Storage Locations
        tka00,          "Control parameters for controlling areas
        tka02,          "Controlling area assignment
        tfacd,          "Factory calendar definition
        aufk,           "Order Data
        t006,           "Units of Measurement
        t023,           "Material Groups
        t007a,          "Tax Keys
        ska1,           "G/L Account Master (Chart of Accounts)
        csks,           "Cost Center Master Record
        anlh,           "Main asset number
        prps.           "WBS (Work Breakdown Structure) Element Master Data

"Selection Screen
SELECTION-SCREEN BEGIN OF SCREEN 101 AS SUBSCREEN.
  PARAMETERS:
*    p_bukrs  TYPE bukrs,
    filename TYPE localfile MEMORY ID zfile,
    p_line   TYPE DEFAULT 6.
SELECTION-SCREEN END OF SCREEN 101 .


Include ZMMC003_02

*&---------------------------------------------------------------------*
*& Include          ZMMC003_02
*&---------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION DEFERRED.
DATA:
  g_event_receiver TYPE REF TO lcl_event_receiver,
  wa_stable        TYPE lvc_s_stbl.
DATA gs_toolbar TYPE stb_button.

CLASS lcl_event_receiver DEFINITION.
  PUBLIC SECTION.
    METHODS:handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
      IMPORTING e_row  e_column.
ENDCLASS.

CLASS lcl_event_receiver IMPLEMENTATION.
  METHOD handle_double_click.
    CLEAR wa_print.
    READ TABLE it_print[] INTO wa_print INDEX e_row-index.
    CASE e_column.
      WHEN 'MATNR'.
        SET PARAMETER ID 'MXX' FIELD 'K'.
        SET PARAMETER ID 'MAT' FIELD wa_print-matnr.
        CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
      WHEN 'SNOTE'.
        SET PARAMETER ID 'BES' FIELD wa_print-sebeln.
        CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.

    ENDCASE.
  ENDMETHOD.
ENDCLASS.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  REFRESH stab.
  IF it_print IS INITIAL.
    APPEND 'POST' TO stab.
    APPEND 'CLRD' TO stab.
  ELSE.
    APPEND 'READ' TO stab.
  ENDIF.

  SET PF-STATUS 'PFS100' EXCLUDING stab.
  SET TITLEBAR  'TTL100' WITH 'Upload Purchase Order'.

  PERFORM initial_screen.
ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
  CASE sy-ucomm.
    WHEN 'BACK' OR 'EXIT' OR 'CNCL'.
      LEAVE PROGRAM.
    WHEN 'READ'.
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
        EXPORTING
          text 'Loading.......'.
      PERFORM read_excel USING filename '1' p_line '30' '32000'.
    WHEN 'POST'.
*      PERFORM check_save.
      IF it_print IS INITIAL.
      ELSE.
        READ TABLE it_print WITH KEY icons '@0A@' TRANSPORTING NO FIELDS.
        IF sy-subrc 0.
          CONCATENATE 'Please check your' 'excel data' INTO vc_msg SEPARATED BY ' '.
          MESSAGE vc_msg TYPE 'S' DISPLAY LIKE 'E'.
        ELSE.
          CONCATENATE 'Do you want upload Purchase Order' '?' INTO vc_str SEPARATED BY ' '.
          PERFORM popup_out USING 'ICON_QUESTION' 'Upload Confirmation' vc_str 'Yes' 'No' 'X' CHANGING vc_ans.

          IF vc_ans '1'.
            PERFORM check_save.
          ELSEIF vc_ans '2'.
            CONCATENATE 'Upload Purchase Order' 'be defect' INTO vc_msg SEPARATED BY ' '.
            MESSAGE vc_msg TYPE 'S' DISPLAY LIKE 'E'.
          ENDIF.
        ENDIF.

      ENDIF.
    WHEN 'CLRD'.
      REFRESH it_print.
  ENDCASE.
ENDMODULE.

FORM initial_screen.
  IF ob_container IS INITIAL.
    CREATE OBJECT ob_container
      EXPORTING
        container_name 'CONTAINER'.

    CREATE OBJECT ob_grid
      EXPORTING
        i_parent ob_container.

    CREATE OBJECT g_event_receiver.
  ENDIF.

  PERFORM set_fieldcat.
  PERFORM set_lyout.
  PERFORM alv_displ_out.

*  SET HANDLER :
*    g_event_handler->handle_button_click FOR ob_grid,
*    g_event_handler->handle_double_click FOR ob_grid.

  CALL METHOD ob_grid->refresh_table_display.

  SET HANDLER :
      g_event_receiver->handle_double_click FOR ob_grid.
ENDFORM.

FORM set_fieldcat.
  REFRESH it_fieldcat.
  PERFORM :
        append_fieldcat USING 'ICONS'    'Status'      'CHAR' '' '' '5' '' 'X' '' '3',
        append_fieldcat USING 'SNOTE'    'Message'     'CHAR' '' '' '40' '' 'X' '' '3'.

  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
      i_structure_name 'ZSMM003_2'
    CHANGING
      ct_fieldcat      it_fieldcat.

  CLEAR wa_fieldcat.
  LOOP AT it_fieldcat INTO wa_fieldcat.
    IF wa_fieldcat-fieldname 'LIFNR' OR wa_fieldcat-fieldname 'BSART'.
      wa_fieldcat-key 'X'.
    ENDIF.
    MODIFY it_fieldcat FROM wa_fieldcat
      TRANSPORTING key WHERE fieldname wa_fieldcat-fieldname.
    CLEAR wa_fieldcat.
  ENDLOOP.
ENDFORM.

FORM set_lyout .
  CLEAR is_lyout.
  is_lyout-zebra        'X'.
  is_lyout-cwidth_opt   'X'.
  is_lyout-box_fname    'MATNR'.
*  is_lyout-no_rowins    = 'X'.
  is_lyout-stylefname   'CSTYL'.
  is_lyout-info_fname   'CLINE'.
  is_lyout-ctab_fname   'CCELL'.
ENDFORM.

FORM append_fieldcat USING p_fname p_fdesc p_dtype p_qfield p_cfield p_olen p_sum p_key p_tabname p_act.
  DATA irows TYPE i.
  CLEAR irows.

  DESCRIBE TABLE it_fieldcat LINES irows.
  irows irows + 1.

  CLEAR wa_fieldcat.
  IF p_fname 'ICONS'.
    wa_fieldcat-icon 'X'.
    wa_fieldcat-just 'C'.
  ENDIF.
  wa_fieldcat-col_pos    irows.
  wa_fieldcat-key        p_key.
  wa_fieldcat-fieldname  p_fname.
  wa_fieldcat-scrtext_l  p_fdesc.
  wa_fieldcat-scrtext_m  p_fdesc.
  wa_fieldcat-scrtext_s  p_fdesc.
  wa_fieldcat-datatype   p_dtype.
  wa_fieldcat-qfieldname p_qfield.
  wa_fieldcat-cfieldname p_cfield.
  wa_fieldcat-outputlen  p_olen.
  wa_fieldcat-do_sum     p_sum.
  wa_fieldcat-tabname    p_tabname.

  APPEND wa_fieldcat TO it_fieldcat.
ENDFORM.

FORM read_excel USING p_file p_bcol p_brow p_ecol p_erow.
  CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
      filename                p_file
      i_begin_col             p_bcol
      i_begin_row             p_brow
      i_end_col               p_ecol
      i_end_row               p_erow
    TABLES
      intern                  itab[]
    EXCEPTIONS
      inconsistent_parameters 1
      upload_ole              2
      OTHERS                  3.

  DATA lv_index TYPE i.
  FIELD-SYMBOLS <fs>.

  LOOP AT itab.
    MOVE itab-col TO lv_index.
    ASSIGN COMPONENT lv_index OF STRUCTURE wa_excel TO <fs>.
    MOVE itab-value TO <fs>.
    AT END OF row.
*      APPEND wa_record TO it_record.

      CLEAR wa_print.
      wa_print-icons '@08@'.
      MOVE-CORRESPONDING wa_excel TO wa_print.

      APPEND wa_print TO it_print.
      CLEAR wa_excel.
    ENDAT.
  ENDLOOP.

*  IF sy-subrc <> 0.
*    vc_msg = sy-subrc.
*    CONDENSE vc_msg.
*    CONCATENATE 'Error' vc_msg 'Problem Uploading Excel Spreadsheet' INTO vc_msg SEPARATED BY ' '.
*    MESSAGE vc_msg TYPE 'S' DISPLAY LIKE 'E'.
*  ENDIF.
ENDFORM.

FORM alv_displ_out.
  CALL METHOD ob_grid->set_table_for_first_display
    EXPORTING
*     is_variant                    = is_varnt      "DISVARIANT
      i_save                        'A'           "CHAR1 - X:Global - U:User - A:All - Space:No
      i_default                     'X'           "CHAR1 - X:Allowed - Space:not
      is_layout                     is_lyout      "LVC_S_LAYO
*     is_print                      = is_print      "LVC_S_PRNT
*     it_toolbar_excluding          = it_excld      "UI_FUNCTIONS
    CHANGING
      it_outtab                     it_print
      it_fieldcatalog               it_fieldcat      "LVC_T_FCAT
*     it_sort                       = it_sort       "LVC_T_SORT
    EXCEPTIONS
      invalid_parameter_combination 1
      program_error                 2
      too_many_lines                3
      OTHERS                        4.
ENDFORM.

Include ZMMC003_03


Include ZMMC003_04

*&---------------------------------------------------------------------*
*& Include          ZMMC003_04
*&---------------------------------------------------------------------*
FORM set_trafc_icon USING p_icn p_set p_all.
  IF p_all AND wa_print-icons <> '@02@' OR p_all 9.
    wa_print-icons p_icn.
  ENDIF.
ENDFORM.

FORM alv_color_set USING p_fld p_col p_int p_inv.
  IF it_color IS INITIAL.
    MOVE p_fld      TO wa_color-fname.
    MOVE p_col      TO wa_color-color-col.
    MOVE p_int      TO wa_color-color-int.
    MOVE p_inv      TO wa_color-color-inv.
    APPEND wa_color TO it_color.

    wa_print-ccell[] it_color[].
  ELSE.
    CLEARvi_colorwa_color.
    LOOP AT it_color INTO wa_color WHERE fname p_fld.
      vi_color vi_color + 1.
      MOVE p_fld      TO wa_color-fname.
      MOVE p_col      TO wa_color-color-col.
      MOVE p_int      TO wa_color-color-int.
      MOVE p_inv      TO wa_color-color-inv.
      MODIFY it_color FROM wa_color.
      EXIT.
      CLEAR wa_color.
    ENDLOOP.

    IF vi_color IS INITIAL.
      MOVE p_fld      TO wa_color-fname.
      MOVE p_col      TO wa_color-color-col.
      MOVE p_int      TO wa_color-color-int.
      MOVE p_inv      TO wa_color-color-inv.
      APPEND wa_color TO it_color.
    ENDIF.

    wa_print-ccell[] it_color[].
  ENDIF.
ENDFORM.

FORM datum_inp USING p_inp CHANGING p_err p_out.
  CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
    EXPORTING
      date_external            p_inp
      accept_initial_date      ''
    IMPORTING
      date_internal            p_out
    EXCEPTIONS
      date_external_is_invalid 1
      OTHERS                   2.

  p_err sy-subrc.
ENDFORM.

*----------------------------------------------------------------------*
FORM datum_out USING p_inp CHANGING p_out.
  CONCATENATE p_inp+6(2p_inp+4(2p_inp+4(4INTO p_out SEPARATED BY '.'.
ENDFORM.

*----------------------------------------------------------------------*
FORM check_uom USING p_uom CHANGING p_err p_msg p_out p_dec.
  CLEARp_errp_msgp_outp_dec.

  CLEARwa_t006a.
  SELECT SINGLE FROM t006a INTO wa_t006a WHERE mseh3 p_uom.
  IF wa_t006a IS INITIAL.
    CLEARwa_t006.
    SELECT SINGLE FROM t006 INTO wa_t006 WHERE msehi p_uom.
    IF wa_t006 IS NOT INITIAL.
      p_out wa_t006-msehi.
      p_dec wa_t006-andec.
    ELSE.
      p_err 1.
      p_msg 'Check UoM: Unit of Measurement not found'.
    ENDIF.
  ELSE.
    CLEARwa_t006.
    SELECT SINGLE FROM t006 INTO wa_t006 WHERE msehi wa_t006a-msehi.
    p_out wa_t006-msehi.
    p_dec wa_t006-andec.
  ENDIF.
ENDFORM.

FORM check_num USING p_num p_uom p_dot p_cur CHANGING p_err p_msg p_out.
  CLEARp_errvx_decp_out.

  IF p_num IS INITIAL.
    p_err 1.
    p_msg 'Check Number: Data null'.
    EXIT.
  ENDIF.

  vc_num p_num.
  REPLACE ALL OCCURRENCES OF ',' IN vc_num WITH '.'.

  CLEAR vi_dec.
  IF p_uom IS NOT INITIAL.
    PERFORM check_uom USING p_uom CHANGING p_err p_msg vc_out vi_dec.
  ELSEIF p_dot IS INITIAL AND p_cur IS INITIAL.
    p_err 1.
    p_msg 'Check Number: No Data reference'.
  ELSEIF p_cur '1'.
    p_msg ''.
    vi_dec 1.
  ELSEIF p_cur '2'.
    p_msg ''.
    vi_dec 2.
  ELSEIF p_cur '3'.
    p_msg ''.
    vi_dec 3.
  ELSEIF p_dot '.' OR p_dot ',' OR p_cur 'USD'.
    p_msg ''.
    vi_dec 2.
  ENDIF.

  CHECK p_err IS INITIAL.
  vi_tmr strlenvc_num ).

  CLEARvi_cntvi_dbl.
  DO vi_tmr TIMES.
    IF    vc_num+vi_cnt(1'0' OR vc_num+vi_cnt(1'1' OR vc_num+vi_cnt(1'2' OR vc_num+vi_cnt(1'3'
      OR  vc_num+vi_cnt(1'4' OR vc_num+vi_cnt(1'5' OR vc_num+vi_cnt(1'6' OR vc_num+vi_cnt(1'7'
      OR  vc_num+vi_cnt(1'8' OR vc_num+vi_cnt(1'9' OR vc_num+vi_cnt(1',' OR vc_num+vi_cnt(1'.'.

      IF vc_num+vi_cnt(1',' OR vc_num+vi_cnt(1'.'.
        vi_dbl vi_dbl + 1.
      ENDIF.

      IF vi_cnt IS INITIAL AND vc_num+vi_cnt(1',' OR vc_num+vi_cnt(1'.' ).
        p_err 1.
        p_msg 'Check Number: Wrong format'.
        EXIT.
      ENDIF.

      IF vi_dbl IS NOT INITIAL AND vi_dec IS NOT INITIAL.
        IF vx_dec > vi_dec.
          p_err 1.
          p_msg 'Check Number: Wrong format'.
          EXIT.
        ENDIF.

        vx_dec vx_dec + 1.
      ENDIF.

      IF    vi_dbl > )
        OR  vi_dec IS INITIAL AND vc_num+vi_cnt(1',' OR vc_num+vi_cnt(1'.' )
        OR vc_num+vi_cnt(1','.

        p_err 1.
        p_msg 'Check Number: Wrong format'.
        EXIT.
      ENDIF.
    ELSE.
      p_err 1.
      p_msg 'Check Number: Wrong format'.
      EXIT.
    ENDIF.
    vi_cnt vi_cnt + 1.
  ENDDO.

  CHECK p_err IS INITIAL.

  IF p_cur 'IDR'.
    p_out vc_num / 100.
  ELSE.
    p_out vc_num.
  ENDIF.
ENDFORM.

FORM alpha_inp USING p_inp CHANGING p_err p_out.
  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
      input  p_inp
    IMPORTING
      output p_out.

  p_err sy-subrc.
ENDFORM.

*----------------------------------------------------------------------*
FORM alpha_out USING p_inp CHANGING p_err p_out.
  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
    EXPORTING
      input  p_inp
    IMPORTING
      output p_out.

  p_err sy-subrc.
ENDFORM.

FORM popup_out USING p_typ p_tit p_txt p_bt1 p_bt2 p_cnc CHANGING p_ans.
  CALL FUNCTION 'POPUP_TO_CONFIRM'
    EXPORTING
      titlebar              p_tit
      text_question         p_txt
      text_button_1         p_bt1 "(001)
      icon_button_1         'ICON_YES'
      text_button_2         p_bt2 "(002)
      icon_button_2         'ICON_NO'
      default_button        '1'
      display_cancel_button p_cnc
*     START_COLUMN          = 25
*     START_ROW             = 6
      popup_type            p_typ
*     IV_QUICKINFO_BUTTON_1 = ' '
*     IV_QUICKINFO_BUTTON_2 = ' '
    IMPORTING
      answer                p_ans
    EXCEPTIONS
      text_not_found        1
      OTHERS                2.
ENDFORM.

FORM pload_out USING p_val p_inf p_tbx p_lne.
  CHECK p_lne IS NOT INITIAL.
  vp_prc p_tbx / p_lne 100.
  vc_prc vp_prc.

  SHIFT vc_prc LEFT DELETING LEADING ' '.

  IF p_val 0.
    CONCATENATE 'Loading..' vc_prc '% Complete' INTO vc_txt SEPARATED BY ' '.
  ELSEIF p_val 1.
    CONCATENATE p_inf '.. ' INTO vc_txt.
    CONCATENATE vc_txt vc_prc '% Complete' INTO vc_txt SEPARATED BY ' '.
  ENDIF.

  IF vp_prc GT vi_max OR p_tbx EQ 1.
    CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
      EXPORTING
        percentage vp_prc
        text       vc_txt.

    vi_max vp_prc.
  ENDIF.
ENDFORM.

Include ZMMC003_05

*&---------------------------------------------------------------------*
*& Include          ZMMC003_05
*&---------------------------------------------------------------------*
FORM check_save.
  REFRESH it_tprnt.
  it_tprnt[] it_print[].

  CLEAR wa_tprnt.
  LOOP AT it_tprnt INTO wa_tprnt WHERE icons <> '@08@' AND icons <> '@09@'.
    DELETE it_tprnt.
    CLEAR wa_tprnt.
  ENDLOOP.

  REFRESH it_zprnt.
  it_zprnt[] it_tprnt[].
  SORT it_zprnt BY unsez.
  DELETE ADJACENT DUPLICATES FROM it_zprnt COMPARING unsez.

  DESCRIBE TABLE it_zprnt LINES vi_print.

  CLEARwa_zprntvi_cld.
  LOOP AT it_zprnt INTO wa_zprnt.
    vi_cld vi_cld + 1.

    CONCATENATE 'Creating Purchase Order' wa_tprnt-unsez INTO vc_msg SEPARATED BY ' '.
    PERFORM pload_out USING vc_msg vi_cld vi_print.

    PERFORM uplod_set.
    CLEAR wa_zprnt.
  ENDLOOP.

  DESCRIBE TABLE it_tprnt LINES vi_print.

  REFRESH it_print.
  it_print[] it_tprnt[].
ENDFORM.

FORM uplod_set .
  PERFORM uplod_exp.
  PERFORM uplod_imp.
  PERFORM uplod_tab.

  CALL FUNCTION 'BAPI_PO_CREATE1'
    EXPORTING
      poheader               ex_poheader
      poheaderx              ex_poheaderx
      poaddrvendor           ex_poaddrvendor
      testrun                ex_testrun
      memory_uncomplete      ex_memory_uncomplete
      memory_complete        ex_memory_complete
      poexpimpheader         ex_poexpimpheader
      poexpimpheaderx        ex_poexpimpheaderx
      versions               ex_versions
      no_messaging           ex_no_messaging
      no_message_req         ex_no_message_req
      no_authority           ex_no_authority
      no_price_from_po       ex_no_price_from_po
      park_complete          ex_park_complete
      park_uncomplete        ex_park_uncomplete
    IMPORTING
      exppurchaseorder       im_exppurchaseorder
      expheader              im_expheader
      exppoexpimpheader      im_exppoexpimpheader
    TABLES
      return                 it_return
      poitem                 it_poitem
      poitemx                it_poitemx
      poaddrdelivery         it_poaddrdelivery
      poschedule             it_poschedule
      poschedulex            it_poschedulex
      poaccount              it_poaccount
      poaccountprofitsegment it_poaccountprofitsegment
      poaccountx             it_poaccountx
      pocondheader           it_pocondheader
      pocondheaderx          it_pocondheaderx
      pocond                 it_pocond
      pocondx                it_pocondx
      polimits               it_polimits
      pocontractlimits       it_pocontractlimits
      poservices             it_poservices
      posrvaccessvalues      it_posrvaccessvalues
      poservicestext         it_poservicestext
      extensionin            it_extensionin
      extensionout           it_extensionout
      poexpimpitem           it_poexpimpitem
      poexpimpitemx          it_poexpimpitemx
      potextheader           it_potextheader
      potextitem             it_potextitem
      allversions            it_allversions
      popartner              it_popartner
      pocomponents           it_pocomponents
      pocomponentsx          it_pocomponentsx
      poshipping             it_poshipping
      poshippingx            it_poshippingx
      poshippingexp          it_poshippingexp
      serialnumber           it_serialnumber
      serialnumberx          it_serialnumberx
      invplanheader          it_invplanheader
      invplanheaderx         it_invplanheaderx
      invplanitem            it_invplanitem
      invplanitemx           it_invplanitemx
      nfmetallitms           it_nfmetallitms.

  DATA zebelp TYPE ebelp.
  CLEARit_returnvc_msg.
  READ TABLE it_return INTO it_return WITH KEY type 'E'.
  IF it_return IS NOT INITIAL.
    wa_zprnt-icons '@F1@'.
    wa_zprnt-snote it_return-message.
    MODIFY it_tprnt FROM wa_zprnt TRANSPORTING icons snote WHERE unsez wa_zprnt-unsez.

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

    CONCATENATE 'Success:' it_return-message_v1 'No.' im_exppurchaseorder INTO vc_msg SEPARATED BY ' '.
    wa_zprnt-icons '@5Y@'.
    wa_zprnt-snote vc_msg.
    wa_zprnt-sebeln im_exppurchaseorder .
    MODIFY it_tprnt FROM wa_zprnt TRANSPORTING icons snote sebeln WHERE unsez wa_zprnt-unsez.
  ENDIF.
ENDFORM.

FORM uplod_exp .
  "--------------------------------------------------------------------------------------------------------------------------------------------------
  CLEAR ex_poheader.
  CLEAR ex_poheaderx.

  ex_poheader-our_ref                               wa_zprnt-unsez.
  IF ex_poheader-our_ref IS NOT INITIAL.
    ex_poheaderx-our_ref                            'X'.
  ENDIF.

  ex_poheader-doc_type                              wa_zprnt-bsart.
  IF ex_poheader-doc_type IS NOT INITIAL.
    ex_poheaderx-doc_type                           'X'.
  ENDIF.

  ex_poheader-doc_date                              wa_zprnt-bedat.
  IF ex_poheader-doc_date   IS NOT INITIAL.
    ex_poheaderx-doc_date                           'X'.
  ENDIF.

  ex_poheader-vendor                                wa_zprnt-lifnr.
  IF ex_poheader-vendor IS NOT INITIAL.
    ex_poheaderx-vendor                             'X'.
  ENDIF.

  ex_poheader-purch_org                             wa_zprnt-ekorg.
  IF ex_poheader-purch_org IS NOT INITIAL.
    ex_poheaderx-purch_org                          'X'.
  ENDIF.

  ex_poheader-pur_group                             wa_zprnt-ekgrp.
  IF ex_poheader-pur_group IS NOT INITIAL.
    ex_poheaderx-pur_group                          'X'.
  ENDIF.

* EX_POHEADER-COMP_CODE                             = WA_ZPRNT-BUKRS.
* IF EX_POHEADER-COMP_CODE IS NOT INITIAL.
*   EX_POHEADERX-COMP_CODE                          = 'X'.
* ENDIF.

  ex_poheader-currency                              wa_zprnt-waers.
  IF ex_poheader-currency IS NOT INITIAL.
    ex_poheaderx-currency                           'X'.
  ENDIF.

  ex_poheader-ex_rate_fx                            'X'.
  IF ex_poheader-ex_rate_fx IS NOT INITIAL.
    ex_poheaderx-ex_rate_fx                         'X'.
  ENDIF.

  ex_poheader-ref_1                                 wa_zprnt-ihrez.
  IF ex_poheader-ref_1 IS NOT INITIAL.
    ex_poheaderx-ref_1                              'X'.
  ENDIF.

  ex_poheader-sales_pers                            wa_zprnt-verkf.
  IF ex_poheader-sales_pers IS NOT INITIAL.
    ex_poheaderx-sales_pers                         'X'.
  ENDIF.

  ex_poheader-pmnttrms                              wa_zprnt-zterm.
  ex_poheaderx-pmnttrms                             'X'.
  "--------------------------------------------------------------------------------------------------------------------------------------------------
  CLEAR ex_poaddrvendor.

  "--------------------------------------------------------------------------------------------------------------------------------------------------
  ex_testrun                                        ''.
  ex_memory_uncomplete                              ''.
  ex_memory_complete                                ''.

  "--------------------------------------------------------------------------------------------------------------------------------------------------
  CLEAR ex_poexpimpheader.
  CLEAR ex_poexpimpheaderx.

  "--------------------------------------------------------------------------------------------------------------------------------------------------
  CLEAR ex_versions.

  "--------------------------------------------------------------------------------------------------------------------------------------------------
  ex_no_messaging                                   ''.
  ex_no_message_req                                 ''.
  ex_no_authority                                   ''.
  ex_no_price_from_po                               'X'.
  ex_park_complete                                  ''.
  ex_park_uncomplete                                ''.

ENDFORM.

*----------------------------------------------------------------------*
FORM uplod_imp .
  CLEAR im_exppurchaseorder.
  CLEAR im_expheader.
  CLEAR im_exppoexpimpheader.
ENDFORM.

*----------------------------------------------------------------------*
FORM uplod_tab .
  REFRESH it_return.

  REFRESH it_poitem.
  REFRESH it_poitemx.

  REFRESH it_poaddrdelivery.
  REFRESH it_poschedule.
  REFRESH it_poschedulex.

  REFRESH it_poaccount.
  REFRESH it_poaccountx.

  REFRESH it_poaccountprofitsegment.

  REFRESH it_pocondheader.
  REFRESH it_pocondheaderx.

  REFRESH it_pocond.
  REFRESH it_pocondx.

  REFRESH it_polimits.
  REFRESH it_pocontractlimits.
  REFRESH it_poservices.
  REFRESH it_posrvaccessvalues.
  REFRESH it_poservicestext.
  REFRESH it_extensionin.
  REFRESH it_extensionout.
  REFRESH it_poexpimpitem.
  REFRESH it_poexpimpitemx.
  REFRESH it_potextheader.
  REFRESH it_potextitem.
  REFRESH it_allversions.
  REFRESH it_popartner.
  REFRESH it_pocomponents.
  REFRESH it_pocomponentsx.
  REFRESH it_poshipping.
  REFRESH it_poshippingx.
  REFRESH it_poshippingexp.
  REFRESH it_serialnumber.
  REFRESH it_serialnumberx.
  REFRESH it_invplanheader.
  REFRESH it_invplanheaderx.
  REFRESH it_invplanitem.
  REFRESH it_invplanitemx.

  "--------------------------------------------------------------------------------------------------------------------------------------------------
  CLEARz_zekknz_etenrz_stunr.

  CLEARwa_tprntz_zekknz_etenrz_stunr.
  LOOP AT it_tprnt INTO wa_tprnt WHERE unsez wa_zprnt-unsez.
    CLEAR wa_poitem.
    READ TABLE it_poitem INTO wa_poitem WITH KEY po_item wa_tprnt-ebelp.

    IF wa_poitem IS INITIAL.
      z_zekkn 1.
      z_etenr 1.
      z_stunr 1.

      CLEAR wa_poitem.
      CLEAR wa_poitemx.

      wa_poitem-po_item                                 wa_tprnt-ebelp.
      IF wa_poitem-po_item IS NOT INITIAL.
        wa_poitemx-po_item                              wa_poitem-po_item.
        wa_poitemx-po_itemx                             'X'.
      ENDIF.

      IF wa_tprnt-knttp IS NOT INITIAL.
        wa_poitem-acctasscat                            wa_tprnt-knttp.
        wa_poitemx-acctasscat                           'X'.
      ENDIF.

      IF wa_tprnt-epstp IS NOT INITIAL.
        wa_poitem-item_cat                              wa_tprnt-epstp.
        wa_poitemx-item_cat                             'X'.
      ENDIF.

*      IF WA_TPRNT-PSTYP = '3'.
*        WA_POITEM-ITEM_CAT                                = 'L'.  "WA_TPRNT-PSTYP.
*        IF WA_POITEM-ITEM_CAT IS NOT INITIAL.
*          WA_POITEMX-ITEM_CAT                             = 'X'.
*        ENDIF.
*      ENDIF.

*      wa_poitem-ematerial                               = wa_tprnt-ematn.
*      if wa_poitem-ematerial is not initial.
*        wa_poitemx-ematerial                            = 'X'.
*
*        wa_poitem-ematerial_long                        = wa_poitem-ematerial.
*        wa_poitemx-ematerial_long                       = 'X'.
*      endif.


      IF wa_tprnt-ematn IS NOT INITIAL.
        wa_poitem-material                              wa_tprnt-ematn.
        wa_poitemx-material                             'X'.

        wa_poitem-material_long                         wa_poitem-material.
        wa_poitemx-material_long                        'X'.
      ENDIF.

      IF wa_tprnt-txz01 IS NOT INITIAL.
        wa_poitem-short_text                            wa_tprnt-txz01.
        wa_poitemx-short_text                           'X'.
      ENDIF.

      wa_poitem-plant                                   wa_tprnt-werks.
      IF wa_poitem-plant IS NOT INITIAL.
        wa_poitemx-plant                                'X'.
      ENDIF.


      IF wa_tprnt-lgort IS NOT INITIAL.
        wa_poitem-stge_loc                              wa_tprnt-lgort.
        wa_poitemx-stge_loc                             'X'.
      ENDIF.

      IF wa_tprnt-meins IS NOT INITIAL.
        wa_poitem-po_unit                               wa_tprnt-meins.
        wa_poitemx-po_unit                              'X'.
      ENDIF.

      IF wa_tprnt-waers 'IDR'.
        wa_tprnt-netpr wa_tprnt-netpr * 100.
      ENDIF.

      IF wa_tprnt-netpr IS NOT INITIAL.
        wa_poitem-net_price                             wa_tprnt-netpr.
        wa_poitemx-net_price                            'X'.
      ENDIF.

      wa_poitem-price_unit                              wa_tprnt-peinh.
      IF wa_poitem-price_unit IS NOT INITIAL.
        wa_poitemx-price_unit                           'X'.
      ENDIF.

      wa_poitem-orderpr_un                              wa_tprnt-bprme.
      IF wa_poitem-orderpr_un IS NOT INITIAL.
        wa_poitemx-orderpr_un                           'X'.
      ENDIF.

      IF wa_tprnt-matkl IS NOT INITIAL.
        wa_poitem-matl_group                            wa_tprnt-matkl.
        wa_poitemx-matl_group                           'X'.
      ENDIF.

      IF wa_tprnt-afnam IS NOT INITIAL.
        wa_poitem-preq_name                             wa_tprnt-afnam.
        wa_poitemx-preq_name                            'X'.
      ENDIF.

      IF wa_tprnt-mwskz IS NOT INITIAL.
        wa_poitem-tax_code                              wa_tprnt-mwskz.
        wa_poitemx-tax_code                             'X'.
      ENDIF.

      IF wa_tprnt-unsez IS NOT INITIAL.
        wa_poitem-trackingno                            wa_tprnt-unsez.
        wa_poitemx-trackingno                           'X'.
      ENDIF.
*QUANTITY
*      WA_POITEM-GR_BASEDIV                              = WA_TPRNT-WEBRE.
*      WA_POITEMX-GR_BASEDIV                             = 'X'.

      IF wa_poitem IS NOT INITIAL.
        APPEND wa_poitem TO it_poitem.
        APPEND wa_poitemx TO it_poitemx.
      ENDIF.

      IF wa_tprnt-knttp IS NOT INITIAL.
        CLEAR wa_poaccount.
        CLEAR wa_poaccountx.

        wa_poaccount-po_item                            wa_tprnt-ebelp.
        IF wa_poaccount-po_item IS NOT INITIAL.
          wa_poaccountx-po_item                         wa_poaccount-po_item.
          wa_poaccountx-po_itemx                        'X'.
        ENDIF.

        wa_poaccount-serial_no                            z_zekkn.
        IF wa_poaccount-serial_no IS NOT INITIAL.
          wa_poaccountx-serial_no                         wa_poaccount-serial_no.
          wa_poaccountx-serial_nox                        'X'.
        ENDIF.

        IF wa_tprnt-anln1 IS NOT INITIAL.
          wa_poaccount-quantity                           wa_tprnt-ktmng.
*          WA_POACCOUNT-QUANTITY                           = WA_TPRNT-SMENGE.
          IF wa_poaccount-quantity IS NOT INITIAL.
            wa_poaccountx-quantity                        'X'.
          ENDIF.
        ENDIF.

*        WA_POACCOUNT-GL_ACCOUNT                           = WA_TPRNT-SAKTO.
*        IF WA_POACCOUNT-GL_ACCOUNT IS NOT INITIAL.
*          WA_POACCOUNTX-GL_ACCOUNT                        = 'X'.
*        ENDIF.

        wa_poaccount-costcenter                           wa_tprnt-kostl.
        IF wa_poaccount-costcenter IS NOT INITIAL.
          wa_poaccountx-costcenter                        'X'.
        ENDIF.

        wa_poaccount-asset_no                             wa_tprnt-anln1.
        IF wa_poaccount-asset_no IS NOT INITIAL.
          wa_poaccountx-asset_no                          'X'.
        ENDIF.

        wa_poaccount-orderid                       wa_tprnt-aufnr.
        IF wa_poaccount-orderid IS NOT INITIAL.
          wa_poaccountx-orderid                       'X'.
        ENDIF.

        IF wa_poaccount IS NOT INITIAL.
          APPEND wa_poaccount TO it_poaccount.
          APPEND wa_poaccountx TO it_poaccountx.
        ENDIF.
      ENDIF.

      CLEAR wa_poschedule.
      CLEAR wa_poschedulex.

      wa_poschedule-po_item                             wa_tprnt-ebelp.
      IF wa_poschedule-po_item IS NOT INITIAL.
        wa_poschedulex-po_item                          wa_poschedule-po_item.
        wa_poschedulex-po_itemx                         'X'.
      ENDIF.

      wa_poschedule-sched_line                          z_etenr.
      IF wa_poschedule-sched_line IS NOT INITIAL.
        wa_poschedulex-sched_line                       wa_poschedule-sched_line.
        wa_poschedulex-sched_linex                      'X'.
      ENDIF.

      CONCATENATE wa_tprnt-eindt+6(2wa_tprnt-eindt+4(2wa_tprnt-eindt+0(4INTO wa_poschedule-delivery_date SEPARATED BY '.'.
*      WA_POSCHEDULE-DELIVERY_DATE                       = WA_TPRNT-EINDT.
      IF wa_poschedule-delivery_date IS NOT INITIAL.
        wa_poschedulex-delivery_date                    'X'.
      ENDIF.

      wa_poschedule-quantity                            wa_tprnt-ktmng.
*      WA_POSCHEDULE-QUANTITY                            = WA_TPRNT-SMENGE.
      IF wa_poschedule-quantity IS NOT INITIAL.
        wa_poschedulex-quantity                         'X'.
      ENDIF.

      IF wa_poschedule IS NOT INITIAL.
        APPEND wa_poschedule TO it_poschedule.
        APPEND wa_poschedulex TO it_poschedulex.
      ENDIF.
    ELSE.
      z_zekkn z_zekkn + 1.
      z_etenr z_etenr + 1.

      IF wa_tprnt-knttp IS NOT INITIAL.
        CLEAR wa_poaccount.
        CLEAR wa_poaccountx.

        wa_poaccount-po_item                              wa_tprnt-ebelp.
        IF wa_poaccount-po_item IS NOT INITIAL.
          wa_poaccountx-po_item                           wa_poaccount-po_item.
          wa_poaccountx-po_itemx                          'X'.
        ENDIF.

        wa_poaccount-serial_no                            z_zekkn.
        IF wa_poaccount-serial_no IS NOT INITIAL.
          wa_poaccountx-serial_no                         wa_poaccount-serial_no.
          wa_poaccountx-serial_nox                        'X'.
        ENDIF.

        IF wa_tprnt-anln1 IS NOT INITIAL.
          wa_poaccount-quantity                           wa_tprnt-ktmng.
*          WA_POACCOUNT-QUANTITY                           = WA_TPRNT-SMENGE.
          IF wa_poaccount-quantity IS NOT INITIAL.
            wa_poaccountx-quantity                        'X'.
          ENDIF.
        ENDIF.

*        WA_POACCOUNT-GL_ACCOUNT                           = WA_TPRNT-SAKTO.
*        IF WA_POACCOUNT-GL_ACCOUNT IS NOT INITIAL.
*          WA_POACCOUNTX-GL_ACCOUNT                        = 'X'.
*        ENDIF.

        wa_poaccount-costcenter                           wa_tprnt-kostl.
        IF wa_poaccount-costcenter IS NOT INITIAL.
          wa_poaccountx-costcenter                        'X'.
        ENDIF.

        wa_poaccount-asset_no                             wa_tprnt-anln1.
        IF wa_poaccount-asset_no IS NOT INITIAL.
          wa_poaccountx-asset_no                          'X'.
        ENDIF.

        wa_poaccount-orderid                          wa_tprnt-aufnr.
        IF wa_poaccount-orderid IS NOT INITIAL.
          wa_poaccountx-orderid                       'X'.
        ENDIF.

        IF wa_poaccount IS NOT INITIAL.
          APPEND wa_poaccount TO it_poaccount.
          APPEND wa_poaccountx TO it_poaccountx.
        ENDIF.
      ENDIF.

      CLEAR wa_poschedule.
      CLEAR wa_poschedulex.

      wa_poschedule-po_item                             wa_tprnt-ebelp.
      IF wa_poschedule-po_item IS NOT INITIAL.
        wa_poschedulex-po_item                          wa_poschedule-po_item.
        wa_poschedulex-po_itemx                         'X'.
      ENDIF.

      wa_poschedule-sched_line                          z_etenr.
      IF wa_poschedule-sched_line IS NOT INITIAL.
        wa_poschedulex-sched_line                       wa_poschedule-sched_line.
        wa_poschedulex-sched_linex                      'X'.
      ENDIF.

      CONCATENATE wa_tprnt-eindt+6(2wa_tprnt-eindt+4(2wa_tprnt-eindt+0(4INTO wa_poschedule-delivery_date SEPARATED BY '.'.
*      WA_POSCHEDULE-DELIVERY_DATE                       = WA_TPRNT-EINDT.
      IF wa_poschedule-delivery_date IS NOT INITIAL.
        wa_poschedulex-delivery_date                    'X'.
      ENDIF.

      wa_poschedule-quantity                            wa_tprnt-ktmng.
*      WA_POSCHEDULE-QUANTITY                            = WA_TPRNT-SMENGE.
      IF wa_poschedule-quantity IS NOT INITIAL.
        wa_poschedulex-quantity                         'X'.
      ENDIF.

      IF wa_poschedule IS NOT INITIAL.
        APPEND wa_poschedule TO it_poschedule.
        APPEND wa_poschedulex TO it_poschedulex.
      ENDIF.
    ENDIF.

    CLEAR wa_tprnt.
  ENDLOOP.
ENDFORM.




Excel Template



Comments

Popular posts from this blog

PHP MySql CRUD Dengan Konsep MVC

Laravel - Sistem Informasi Perpustakaan Sederhana Laravel

IT Asset Management Dengan PHP MySQL