qp01 Upload
qp01 Upload
qp01 Upload
PERFORM f4value.
START-OF-SELECTION.
PERFORM upload.
IF ist_itab[] IS INITIAL.
MESSAGE 'No records selected.. Check file name.' TYPE 'E'.
EXIT.
ELSE.
PERFORM bdc_fill.
ENDIF.
PERFORM displayalv.
FORM f4value.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM.
FORM upload.
REFRESH ist_itab[].
** ELSE.
** MESSAGE e398(00) WITH 'Invalid File Type'.
** ENDIF.
IF ist_itab IS INITIAL.
MESSAGE 'No records to upload' TYPE 'E'.
ENDIF.
ENDFORM.
FORM bdc_transaction.
DATA: l_mstring(480).
DATA: l_subrc LIKE sy-subrc.
DATA: lx_auth_check TYPE REF TO cx_root.
DATA: l_auth_check_text TYPE string.
* batch input session
TRY.
CALL TRANSACTION 'QP01' WITH AUTHORITY-CHECK USING bdcdata
MODE p_mode
UPDATE 'A'
MESSAGES INTO messtab.
CATCH cx_sy_authorization_error INTO lx_auth_check.
* Authorization missing for user when executing transaction
l_auth_check_text = lx_auth_check->get_text( ).
sy-subrc = 99.
ENDTRY.
l_subrc = sy-subrc.
* WRITE: / 'CALL_TRANSACTION',
* 'QP01',
* 'returncode:'(i05),
* l_subrc,
* 'RECORD:',
* sy-index.
IF l_subrc <> 99.
LOOP AT messtab.
MESSAGE ID messtab-msgid
TYPE messtab-msgtyp
NUMBER messtab-msgnr
INTO l_mstring
WITH messtab-msgv1
messtab-msgv2
messtab-msgv3
messtab-msgv4.
* WRITE: / messtab-msgtyp, 'Material', wa_itab-matnr, l_mstring(250).
it_loghead-matnr = wa_itab-matnr.
it_loghead-msgno = messtab-msgnr.
it_loghead-msgtype = messtab-msgtyp.
REFRESH bdcdata.
ENDFORM.
FORM bdc_fill .
LOOP AT ist_itab INTO wa_itab.
wa_itab-kurztext = wa_itab-verwmerkm.
TRANSLATE wa_itab-verwmerkm TO UPPER CASE.
PERFORM bdc_dynpro USING 'SAPLCPDI' '8010'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RC27M-WERKS'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=XALU'.
PERFORM bdc_field USING 'RC27M-MATNR'
wa_itab-matnr.
PERFORM bdc_field USING 'RC27M-WERKS'
wa_itab-werks.
PERFORM bdc_field USING 'RC271-STTAG'
wa_itab-sttag.
* PERFORM bdc_dynpro USING 'SAPLCPDA' '1200'.
* PERFORM bdc_field USING 'BDC_OKCODE'
* '=VOUE'.
* PERFORM bdc_field USING 'BDC_SUBSCR' 'SAPLCPDA
1210GENERAL'.
** PERFORM bdc_field USING 'BDC_CURSOR'
** 'PLKOD-PLNAL(01)'.
* PERFORM bdc_field USING 'RC27X-ENTRY_ACT'
* '1'.
* PERFORM bdc_field USING 'RC27X-FLG_SEL(01)'
* 'X'.
PERFORM bdc_transaction.
ENDLOOP.
ENDFORM.
FORM displayalv .
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-seltext_m = 'Material'.
wa_fieldcat-seltext_l = 'Material'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'MSGTYPE'.
wa_fieldcat-seltext_m = 'Message Type'.
wa_fieldcat-seltext_l = 'Message Type'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'MSGNO'.
wa_fieldcat-seltext_m = 'Message No'.
wa_fieldcat-seltext_l = 'Message No'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'MSG'.
wa_fieldcat-seltext_m = 'Message'.
wa_fieldcat-seltext_l = 'Message'.
wa_fieldcat-outputlen = '100'.
APPEND wa_fieldcat TO it_fieldcat.
* wa_itab-verwe.wa_itab-statu.wa_itab-losvn. wa_itab-steus.
* wa_itab-stichprver. wa_itab-quantitat.