REPORT zmm_me12_batch.
********************************
* INNITIALIZATION
********************************
TYPES: BEGIN OF lty_infor,
werks TYPE marc-werks,
infnr TYPE eina-infnr,
kbetr TYPE konp-kbetr,
kpein TYPE konp-kpein, "//per
aplfz TYPE eine-aplfz, "//plan.deliv.time
bstma TYPE eine-bstma,
tcode TYPE bdc_tcode,
msgtyp TYPE bdc_mart,
fldname TYPE fnam_____4,
message_text TYPE char200,
END OF lty_infor.
DATA: lt_infor TYPE TABLE OF lty_infor,
ls_infor LIKE LINE OF lt_infor.
DATA: lt_upload LIKE TABLE OF alsmex_tabline,
ls_upload LIKE LINE OF lt_upload.
DATA: gt_bdc_message_all TYPE TABLE OF zsbdc_message_all, "//ALV显示所有返回信息
ls_bdc_message_all LIKE LINE OF gt_bdc_message_all,
lt_bdcmsg TYPE TABLE OF bdcmsgcoll,
gt_bdc_message TYPE TABLE OF zsbdc_message_all, "// 返回带MESSAGE TEXT
lwa_bdcmsg_all LIKE LINE OF gt_bdc_message,
lwa_bdcmsg LIKE LINE OF lt_bdcmsg,
gt_bdc TYPE STANDARD TABLE OF bdcdata.
DATA: g_update_flag TYPE char1 VALUE 'X'. "//should be updated
********************************
* SELECTION-SCREEN
********************************
SELECTION-SCREEN BEGIN OF BLOCK blk01 WITH FRAME.
PARAMETERS:
p_ekorg TYPE eine-ekorg OBLIGATORY DEFAULT '0080', "//perchase organization
p_werks TYPE eine-werks DEFAULT '0080' OBLIGATORY,
*p_datat type RV13A-DATAB DEFAULT sy-datum,
p_datab TYPE rv13a-datab DEFAULT sy-datum.
PARAMETERS: p_path LIKE ibipparms-path OBLIGATORY.
SELECTION-SCREEN END OF BLOCK blk01.
********************************
* AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
********************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
PERFORM frm_get_filepath USING p_path.
********************************
* START OF SELECTION
********************************
START-OF-SELECTION.
PERFORM frm_upload_data.
IF lt_infor IS NOT INITIAL AND g_update_flag = 'X'.
PERFORM frm_get_data.
PERFORM frm_update_price.
PERFORM frm_alv_diplay.
ELSE.
PERFORM frm_alv_diplay.
ENDIF.
*&---------------------------------------------------------------------*
*& Form FRM_GET_FILEPATH
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_P_PATH text
*----------------------------------------------------------------------*
FORM frm_get_filepath USING p_p_path.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = p_path.
ENDFORM. " FRM_GET_FILEPATH
*&---------------------------------------------------------------------*
*& Form FRM_UPLOAD_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_upload_data .
DATA: lc_fname TYPE rlgrap-filename.
DATA: iv_line TYPE sy-tabix,
l_previous_line TYPE sy-tabix,
l_sytabix TYPE sy-tabix,
l_next_line TYPE sy-tabix,
l_mod TYPE i.
DATA: ls_upload_next LIKE LINE OF lt_upload.
DATA: lwa_upload LIKE LINE OF lt_upload.
lc_fname = p_path.
CLEAR lt_upload[].
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = lc_fname
i_begin_col = 2
i_begin_row = 2
i_end_col = 6
i_end_row = 65536
TABLES
intern = lt_upload
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
IF lt_upload IS NOT INITIAL.
SORT lt_upload BY row col.
CLEAR lt_infor[].
CLEAR ls_upload.
LOOP AT lt_upload INTO ls_upload.
CLEAR l_next_line.
l_next_line = sy-tabix + 1.
CASE ls_upload-col.
WHEN 1. "// infor record
CONDENSE ls_upload-value.
ls_infor-infnr = ls_upload-value.
* IF ls_infor-infnr IS INITIAL.
* ls_infor-message_text = 'field shoud be filled.'.
* g_update_flag = ''.
* CONTINUE.
* ENDIF.
CLEAR lwa_upload.
READ TABLE lt_upload INTO lwa_upload WITH KEY row = ls_upload-row col = 2.
IF sy-subrc NE 0.
* ls_infor-kbetr = 'NULL'.
ls_infor-message_text = 'price is empty.'.
ls_infor-msgtyp = 'E'.
g_update_flag = ''.
APPEND ls_infor TO lt_infor.
CLEAR ls_infor.
CONTINUE.
ENDIF.
WHEN 2. "// price
CONDENSE ls_upload-value.
ls_infor-kbetr = ls_upload-value.
* APPEND ls_infor TO lt_infor.
* CLEAR ls_infor.
WHEN 3. "//Condition pricing unit, per
CONDENSE ls_upload-value.
IF ls_upload-value IS INITIAL.
ls_infor-kpein = '1'.
ELSE.
ls_infor-kpein = ls_upload-value.
ENDIF.
WHEN 4. "//plan.deliv.time
CONDENSE ls_upload-value.
ls_infor-aplfz = ls_upload-value.
WHEN 5. "//Max. Quantity
CONDENSE ls_upload-value.
ls_infor-bstma = ls_upload-value.
ENDCASE.
CLEAR ls_upload_next.
READ TABLE lt_upload INTO ls_upload_next INDEX l_next_line.
IF ls_upload_next-row NE ls_upload-row.
IF ls_infor-kpein IS INITIAL.
ls_infor-kpein = 1.
ENDIF.
IF ls_infor-aplfz IS INITIAL.
* ls_infor-message_text = 'plan.deliv.time is empty.'.
* ls_infor-msgtyp = 'E'.
* g_update_flag = ''.
ls_infor-msgtyp = '1'. "// need to be cleared before update. means plan.deliv.time is empty.
ENDIF.
ls_infor-werks = p_werks.
APPEND ls_infor TO lt_infor.
CLEAR ls_infor.
ENDIF.
CLEAR ls_upload.
ENDLOOP.
ENDIF.
ENDFORM. "frm_upload_data
*&---------------------------------------------------------------------*
*& Form FRM_GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_get_data .
ENDFORM. " FRM_GET_DATA
*&---------------------------------------------------------------------*
*& Form frm_update_price
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_update_price .
"//ZME12_2
CLEAR ls_infor.
LOOP AT lt_infor INTO ls_infor.
PERFORM frm_bdc_update.
CLEAR ls_infor.
ENDLOOP.
ENDFORM. " frm_update_price
*&---------------------------------------------------------------------*
*& Form FRM_BDC_UPDATE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_bdc_update .
DATA: l_group LIKE apqi-groupid, l_user LIKE apqi-userid ,l_keep LIKE apqi-qerase ,l_holddate LIKE apqi-startdate,
l_ctu LIKE apqi-putactive VALUE 'X',
l_mode TYPE c VALUE 'N',
l_update LIKE apqi-putactive VALUE 'N',
l_nodata VALUE '/'.
*perform open_dataset using dataset.
PERFORM open_group USING l_group
l_user
l_keep
l_holddate
l_ctu.
IF ls_infor-aplfz = 0 AND ls_infor-msgtyp = '1'. "// plan.deliv.time is empty. 不填写 plan.deliv.time
CLEAR ls_infor-msgtyp.
CLEAR ls_infor-aplfz.
PERFORM bdc_dynpro USING 'SAPMM06I' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR'
'EINA-INFNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'EINA-LIFNR'
''.
PERFORM bdc_field USING 'EINA-MATNR'
''.
PERFORM bdc_field USING 'EINE-EKORG'
p_ekorg.
PERFORM bdc_field USING 'EINE-WERKS'
p_werks.
PERFORM bdc_field USING 'EINA-INFNR'
ls_infor-infnr.
PERFORM bdc_field USING 'RM06I-NORMB'
'X'.
PERFORM bdc_dynpro USING 'SAPMM06I' '0101'.
PERFORM bdc_field USING 'BDC_CURSOR'
'EINA-MAHN1'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=KO'.
PERFORM bdc_dynpro USING 'SAPLV14A' '0102'.
PERFORM bdc_field USING 'BDC_CURSOR'
'VAKE-DATAB(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=NEWD'.
PERFORM bdc_dynpro USING 'SAPMV13A' '0201'.
PERFORM bdc_field USING 'BDC_CURSOR'
'KONP-KBETR(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RV13A-DATAB'
p_datab.
PERFORM bdc_field USING 'RV13A-DATBI'
'99991231'.
PERFORM bdc_field USING 'KONP-KBETR(01)'
ls_infor-kbetr.
PERFORM bdc_field USING 'KONP-KPEIN(01)'
ls_infor-kpein. "//Condition pricing unit per
PERFORM bdc_dynpro USING 'SAPMV13A' '0201'.
PERFORM bdc_field USING 'BDC_CURSOR'
'KONP-KBETR(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=SICH'.
PERFORM bdc_field USING 'RV13A-DATAB'
p_datab.
PERFORM bdc_field USING 'RV13A-DATBI'
'99991231'.
*******************Begin Of Max. Quantity**********************
PERFORM bdc_dynpro USING 'SAPMM06I' '0102'.
PERFORM bdc_field USING 'BDC_CURSOR'
'EINE-BSTMA'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=KO'.
PERFORM bdc_field USING 'EINE-BSTMA'
ls_infor-bstma.
******************End Of Max. Quantity*************************
ELSE. "// 更新 plan.deliv.time
PERFORM bdc_dynpro USING 'SAPMM06I' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RM06I-NORMB'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'EINA-LIFNR'
''.
PERFORM bdc_field USING 'EINA-MATNR'
''.
PERFORM bdc_field USING 'EINE-EKORG'
p_ekorg.
PERFORM bdc_field USING 'EINE-WERKS'
p_werks.
PERFORM bdc_field USING 'EINA-INFNR'
ls_infor-infnr.
PERFORM bdc_field USING 'RM06I-NORMB'
'X'.
PERFORM bdc_dynpro USING 'SAPMM06I' '0101'.
PERFORM bdc_field USING 'BDC_CURSOR'
'EINA-MAHN1'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_dynpro USING 'SAPMM06I' '0102'.
PERFORM bdc_field USING 'BDC_CURSOR'
'EINE-BSTAE'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=KO'.
PERFORM bdc_field USING 'EINE-APLFZ'
ls_infor-aplfz.
PERFORM bdc_field USING 'EINE-BSTMA'
ls_infor-bstma.
PERFORM bdc_dynpro USING 'SAPLV14A' '0102'.
PERFORM bdc_field USING 'BDC_CURSOR'
'VAKE-DATAB(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=NEWD'.
PERFORM bdc_dynpro USING 'SAPMV13A' '0201'.
PERFORM bdc_field USING 'BDC_CURSOR'
'KONP-KONWA(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=SICH'.
PERFORM bdc_field USING 'RV13A-DATAB'
p_datab.
PERFORM bdc_field USING 'RV13A-DATBI'
'99991231'.
PERFORM bdc_field USING 'KONP-KBETR(01)'
ls_infor-kbetr.
PERFORM bdc_field USING 'KONP-KPEIN(01)'
ls_infor-kpein. "//Condition pricing unit per
ENDIF.
*//=============================================
*//调用BDC
*//=============================================
"// 报错的消息放在循环外, 整体给出报错的消息
* DATA: L_MODE TYPE C VALUE 'N'. "//A=整个过程显示;E=有错误发生的时候显示;N=无论什么情况都不显示
CALL TRANSACTION 'ME12'
USING gt_bdc
MODE l_mode
UPDATE 'S'
MESSAGES INTO lt_bdcmsg.
PERFORM close_group USING l_ctu.
* perform close_dataset using dataset.
CLEAR gt_bdc[].
*//=============================================
*//字段错误返回信息文字描述
*//=============================================
CLEAR lwa_bdcmsg_all.
IF lt_bdcmsg IS NOT INITIAL .
CLEAR lwa_bdcmsg.
LOOP AT lt_bdcmsg INTO lwa_bdcmsg.
lwa_bdcmsg_all-tcode = lwa_bdcmsg-tcode.
lwa_bdcmsg_all-msgtyp = lwa_bdcmsg-msgtyp.
lwa_bdcmsg_all-msgid = lwa_bdcmsg-msgid.
lwa_bdcmsg_all-msgnr = lwa_bdcmsg-msgnr.
lwa_bdcmsg_all-msgv1 = lwa_bdcmsg-msgv1.
lwa_bdcmsg_all-msgv2 = lwa_bdcmsg-msgv2.
lwa_bdcmsg_all-msgv3 = lwa_bdcmsg-msgv3.
lwa_bdcmsg_all-msgv4 = lwa_bdcmsg-msgv4.
PERFORM build_message USING lwa_bdcmsg-msgid
lwa_bdcmsg-msgnr
lwa_bdcmsg-msgv1
lwa_bdcmsg-msgv2
lwa_bdcmsg-msgv3
lwa_bdcmsg-msgv4
CHANGING lwa_bdcmsg_all-message_text.
*
* APPEND lwa_bdcmsg_all TO gt_bdc_message_all.
ls_infor-werks = p_werks.
ls_infor-tcode = lwa_bdcmsg-tcode.
ls_infor-msgtyp = lwa_bdcmsg-msgtyp.
IF lwa_bdcmsg-msgtyp NE 'S'.
REPLACE '/' WITH '' INTO ls_infor-fldname.
CONDENSE: ls_infor-fldname, lwa_bdcmsg-fldname.
IF ls_infor-fldname NE lwa_bdcmsg-fldname.
CONCATENATE ls_infor-fldname lwa_bdcmsg-fldname INTO ls_infor-fldname SEPARATED BY '/'.
ENDIF.
ENDIF.
CONCATENATE ls_infor-message_text lwa_bdcmsg_all-message_text INTO ls_infor-message_text SEPARATED BY '/'.
REPLACE ' see next message ' WITH '' INTO ls_infor-message_text.
REPLACE ' ' WITH '' INTO ls_infor-message_text.
CLEAR lwa_bdcmsg_all.
CLEAR lwa_bdcmsg.
ENDLOOP.
ls_infor-werks = p_werks.
MODIFY lt_infor FROM ls_infor.
CLEAR lt_bdcmsg[].
* CLEAR gt_bdc_message_all[].
ENDIF.
"//DD01T DD03T
ENDFORM. " FRM_BDC_UPDATE
*&---------------------------------------------------------------------*
*& Form open_group
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GROUP text
* -->P_USER text
* -->P_KEEP text
* -->P_HOLDDATE text
* -->P_CTU text
*----------------------------------------------------------------------*
FORM open_group
USING p_group LIKE apqi-groupid
p_user LIKE apqi-userid
p_keep LIKE apqi-qerase
p_holddate LIKE apqi-startdate
p_ctu LIKE apqi-putactive.
IF p_ctu <> 'X'.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
client = sy-mandt
group = p_group
user = p_user
keep = p_keep
holddate = p_holddate.
ENDIF.
ENDFORM. "OPEN_GROUP
*----------------------------------------------------------------------*
* end batchinput session *
*----------------------------------------------------------------------*
FORM close_group USING p_ctu LIKE apqi-putactive.
IF p_ctu <> 'X'.
* close batchinput group
CALL FUNCTION 'BDC_CLOSE_GROUP'.
ENDIF.
ENDFORM. "CLOSE_GROUP
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0078 text
* -->P_0079 text
*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM bdc_dynpro USING program dynpro.
DATA: lwa_bdc LIKE LINE OF gt_bdc.
CLEAR lwa_bdc.
lwa_bdc-program = program.
lwa_bdc-dynpro = dynpro.
lwa_bdc-dynbegin = 'X'.
APPEND lwa_bdc TO gt_bdc.
ENDFORM. "BDC_DYNPRO
*} INSERT
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
DATA: lwa_bdc LIKE LINE OF gt_bdc.
CLEAR lwa_bdc.
lwa_bdc-fnam = fnam.
lwa_bdc-fval = fval.
CONDENSE lwa_bdc-fval.
APPEND lwa_bdc TO gt_bdc.
ENDFORM. "BDC_FIELD
*&---------------------------------------------------------------------*
*& Form BUILD_MESSAGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_MESSTAB_MSGID text
* -->P_MESSTAB_MSGNR text
* -->P_MESSTAB_MSGV1 text
* -->P_MESSTAB_MSGV2 text
* -->P_MESSTAB_MSGV3 text
* -->P_MESSTAB_MSGV4 text
* <--P_E_MSG text
*----------------------------------------------------------------------*
FORM build_message USING u_msgid
u_msgnr
u_msgv1
u_msgv2
u_msgv3
u_msgv4
CHANGING c_message.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = u_msgid
msgnr = u_msgnr
msgv1 = u_msgv1
msgv2 = u_msgv2
msgv3 = u_msgv3
msgv4 = u_msgv4
IMPORTING
message_text_output = c_message. " BUILD_MESSAGE
ENDFORM. "build_message
*&---------------------------------------------------------------------*
*& Form FRM_ALV_DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_alv_diplay .
DATA: l_repid TYPE sy-repid,
ls_layout TYPE slis_layout_alv,
l_grid_settings TYPE lvc_s_glay,
lt_event TYPE slis_t_event,
lt_fieldcat TYPE slis_t_fieldcat_alv.
* DATA: "lt_event TYPE slis_t_event,
* ls_event TYPE slis_alv_event,
* lt_event LIKE TABLE OF ls_event.
PERFORM frm_build_layout CHANGING ls_layout.
* lt_fieldcat TYPE slis_t_fieldcat_alv.
PERFORM frm_build_fieldcat CHANGING lt_fieldcat.
PERFORM frm_build_event CHANGING lt_event.
* PERFORM FRM_BUILD_COMMENT CHANGING LT_COMMENT.
MOVE sy-repid TO l_repid.
* l_grid_settings-edt_cll_cb = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = l_repid
is_layout = ls_layout
* i_grid_settings = l_grid_settings
it_fieldcat = lt_fieldcat
it_events = lt_event
i_callback_user_command = 'FRM_USER_COMMAND'
i_callback_pf_status_set = 'FRM_PF_STATUS_SET'
TABLES
t_outtab = lt_infor.
ENDFORM. " FRM_ALV_DISPLAY
*&---------------------------------------------------------------------*
*& Form frm_build_layout
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->CS_LAYOUT text
*----------------------------------------------------------------------*
FORM frm_build_layout CHANGING cs_layout TYPE slis_layout_alv.
CLEAR cs_layout.
MOVE 'X' TO cs_layout-detail_popup.
MOVE 'X' TO cs_layout-colwidth_optimize.
MOVE 'COLOR' TO cs_layout-info_fieldname.
* MOVE 'SELECTED' TO cs_layout-box_fieldname.
ENDFORM. "frm_build_layout
*&---------------------------------------------------------------------*
*& Form frm_build_fieldcat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->CT_FIELDCAT text
*----------------------------------------------------------------------*
FORM frm_build_fieldcat CHANGING ct_fieldcat TYPE slis_t_fieldcat_alv.
DATA: ls_fieldcat LIKE LINE OF ct_fieldcat.
DATA: l_col_pos TYPE i.
REFRESH ct_fieldcat.
* CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
* EXPORTING
* i_structure_name = 'ZSQM_002_DISPLAY'
* CHANGING
* ct_fieldcat = ct_fieldcat.
* DELETE ct_fieldcat WHERE fieldname = 'SCHRW'.
CLEAR l_col_pos.
l_col_pos = 1.
* kbetr TYPE konp-kbetr,
* tcode TYPE bdc_tcode,
* msgtyp TYPE bdc_mart,
* fldname TYPE fnam_____4,
* message_text TYPE char200,
CLEAR ls_fieldcat.
ls_fieldcat-col_pos = l_col_pos.
ls_fieldcat-fieldname = 'WERKS'.
ls_fieldcat-seltext_l = 'Plant'.
ls_fieldcat-seltext_m = 'Plant'.
ls_fieldcat-seltext_s = 'Plant'.
l_col_pos = l_col_pos + 1.
APPEND ls_fieldcat TO ct_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-col_pos = l_col_pos.
ls_fieldcat-fieldname = 'INFNR'.
ls_fieldcat-seltext_l = 'Infor Record'.
ls_fieldcat-seltext_m = 'Infor Record'.
ls_fieldcat-seltext_s = 'Infor'.
l_col_pos = l_col_pos + 1.
APPEND ls_fieldcat TO ct_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-col_pos = l_col_pos.
ls_fieldcat-fieldname = 'KBETR'.
ls_fieldcat-seltext_l = 'Price'.
ls_fieldcat-seltext_m = 'Price'.
ls_fieldcat-seltext_s = 'Price'.
l_col_pos = l_col_pos + 1.
APPEND ls_fieldcat TO ct_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-col_pos = l_col_pos.
ls_fieldcat-fieldname = 'KPEIN'.
ls_fieldcat-seltext_l = 'per'.
ls_fieldcat-seltext_m = 'per'.
ls_fieldcat-seltext_s = 'per'.
l_col_pos = l_col_pos + 1.
APPEND ls_fieldcat TO ct_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-col_pos = l_col_pos.
ls_fieldcat-fieldname = 'APLFZ'.
ls_fieldcat-seltext_l = 'plan.deliv.time'.
ls_fieldcat-seltext_m = 'plan.deliv.time'.
ls_fieldcat-seltext_s = 'plan.deliv.time'.
l_col_pos = l_col_pos + 1.
APPEND ls_fieldcat TO ct_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-col_pos = l_col_pos.
ls_fieldcat-fieldname = 'BSTMA'.
ls_fieldcat-seltext_l = 'Max. Quantity'.
ls_fieldcat-seltext_m = 'Max. Quantity'.
ls_fieldcat-seltext_s = 'Max. Quantity'.
l_col_pos = l_col_pos + 1.
APPEND ls_fieldcat TO ct_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-col_pos = l_col_pos.
ls_fieldcat-fieldname = 'TCODE'.
ls_fieldcat-seltext_l = 'TCODE'.
ls_fieldcat-seltext_m = 'TCODE'.
ls_fieldcat-seltext_s = 'TCODE'.
l_col_pos = l_col_pos + 1.
APPEND ls_fieldcat TO ct_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-col_pos = l_col_pos.
ls_fieldcat-fieldname = 'MSGTYP'.
ls_fieldcat-seltext_l = 'Message Type'.
ls_fieldcat-seltext_m = 'Message Type'.
ls_fieldcat-seltext_s = 'Type'.
l_col_pos = l_col_pos + 1.
APPEND ls_fieldcat TO ct_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-col_pos = l_col_pos.
ls_fieldcat-fieldname = 'FLDNAME'.
ls_fieldcat-seltext_l = 'Field Name'.
ls_fieldcat-seltext_m = 'Field Name'.
ls_fieldcat-seltext_s = 'Field'.
l_col_pos = l_col_pos + 1.
APPEND ls_fieldcat TO ct_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-col_pos = l_col_pos.
ls_fieldcat-fieldname = 'MESSAGE_TEXT'.
ls_fieldcat-seltext_l = 'MESSAGE_TEXT'.
ls_fieldcat-seltext_m = 'MESSAGE_TEXT'.
ls_fieldcat-seltext_s = 'MESSAGE_TEXT'.
l_col_pos = l_col_pos + 1.
APPEND ls_fieldcat TO ct_fieldcat.
ENDFORM. "frm_build_fieldcat
*&---------------------------------------------------------------------*
*& Form frm_build_event
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->CT_EVENTS text
*----------------------------------------------------------------------*
FORM frm_build_event CHANGING ct_events TYPE slis_t_event.
DATA: "lt_event TYPE slis_t_event,
ls_event TYPE slis_alv_event,
lt_event LIKE TABLE OF ls_event.
REFRESH ct_events.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 4
IMPORTING
et_events = lt_event.
IF g_update_flag = ''.
READ TABLE lt_event WITH KEY name = slis_ev_top_of_page INTO ls_event.
IF sy-subrc = 0.
MOVE 'FRM_TOP_OF_PAGE' TO ls_event-form.
APPEND ls_event TO ct_events.
ENDIF.
ENDIF.
READ TABLE lt_event WITH KEY name = slis_ev_pf_status_set INTO ls_event.
IF sy-subrc = 0.
MOVE 'FRM_PF_STATUS_SET' TO ls_event-form.
APPEND ls_event TO ct_events.
ENDIF.
READ TABLE lt_event WITH KEY name = slis_ev_user_command INTO ls_event.
IF sy-subrc = 0.
MOVE 'FRM_USER_COMMAND' TO ls_event-form.
APPEND ls_event TO ct_events.
ENDIF.
ENDFORM. "frm_build_event
*&---------------------------------------------------------------------*
*& Form frm_build_comment
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->CT_COMMENT text
*----------------------------------------------------------------------*
FORM frm_build_comment CHANGING ct_comment TYPE slis_t_listheader.
DATA: ls_comment TYPE slis_listheader.
REFRESH ct_comment.
CLEAR ls_comment.
ls_comment-typ = 'H'.
ls_comment-info = 'Update not excute.'.
APPEND ls_comment TO ct_comment.
CLEAR ls_comment.
ls_comment-typ = 'S'.
ls_comment-key = 'Uploaded File Error: '.
ls_comment-info = 'Please see detailed messages.'.
APPEND ls_comment TO ct_comment.
ENDFORM. "frm_build_comment
*&---------------------------------------------------------------------*
*& Form frm_top_of_page
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM frm_top_of_page.
DATA: lt_comment TYPE slis_t_listheader.
PERFORM frm_build_comment CHANGING lt_comment.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = lt_comment.
ENDFORM. "frm_top_of_page
*&---------------------------------------------------------------------*
*& Form frm_user_command
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->U_UCOMM text
* -->US_SELECTE_FIELD text
*----------------------------------------------------------------------*
FORM frm_user_command USING u_ucomm LIKE sy-ucomm
us_selecte_field TYPE slis_selfield.
* DATA: lt_selected TYPE TABLE OF zsqm_002_display,
* ls_selected LIKE LINE OF lt_selected.
* DATA: l_lines TYPE i VALUE 0.
CASE u_ucomm.
WHEN '&IC1'. "//点击行"
"//取得用户选择的行
* READ TABLE gt_display INTO ls_display INDEX us_selecte_field-tabindex.
WHEN 'PRINT'. "//打印
* "//取得用户选择的行
* CLEAR ls_selected.
* CLEAR lt_selected[]. "//所有需要打印内容总表
* CLEAR LT_PRINT[].
ENDCASE.
ENDFORM. "frm_user_command
*&---------------------------------------------------------------------*
*& Form frm_pf_status_set
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->UT_EXCLUDE text
*----------------------------------------------------------------------*
FORM frm_pf_status_set USING ut_exclude TYPE slis_t_extab.
SET PF-STATUS 'PF_STAUTS'.
ENDFORM. "frm_pf_status_set