REPORT ZETM_BDC_J4GD.
************************************************************************
*TYPE-POOLS *
************************************************************************
TYPE-POOLS TRUXS.
************************************************************************
*TYPE DECLARATION *
************************************************************************
TYPES : BEGIN OF TYPE_BDCDATA,
PROGRAM TYPE BDC_PROG,
DYNPRO TYPE BDC_DYNR,
DYNBEGIN TYPE BDC_START,
FNAM TYPE FNAM_____4,
FVAL TYPE BDC_FVAL,
END OF TYPE_BDCDATA,
BEGIN OF TYPE_DATA,
EQUNR TYPE EQUNR,
J_3GLVART TYPE J_3GLVART,
J_3GBLTYP1 TYPE J_3GBLTYP,
PLTYP1 TYPE PLTYP,
J_3GBLTYP2 TYPE J_3GBLTYP,
PLTYP2 TYPE PLTYP,
END OF TYPE_DATA.
************************************************************************
*WORK AREA DECLARATION *
************************************************************************
DATA : WA_BDCDATA TYPE TYPE_BDCDATA,
WA_DATA TYPE TYPE_DATA,
WA_MESSTAB TYPE BDCMSGCOLL,
WA_RAW TYPE TRUXS_T_TEXT_DATA.
************************************************************************
*INTERNAL TABLE DECLARATION *
************************************************************************
DATA : I_BDCDATA TYPE STANDARD TABLE OF TYPE_BDCDATA,
I_DATA TYPE STANDARD TABLE OF TYPE_DATA,
I_MESSTAB TYPE STANDARD TABLE OF BDCMSGCOLL.
************************************************************************
*DATA DECLARATION *
************************************************************************
DATA WF_MESSAGE(100).
************************************************************************
*SELECTION-SCREEN DECLARATION *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FILE TYPE LOCALFILE OBLIGATORY,
P_MODE DEFAULT 'A'.
SELECTION-SCREEN END OF BLOCK A1.
************************************************************************
*AT SELECTION-SCREEN ON VALUE-REQUEST DECLARATION *
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
FIELD_NAME = 'P_FILE'
CHANGING
FILE_NAME = P_FILE .
REFRESH I_DATA[].
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = WA_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = I_DATA
.
************************************************************************
*START-OF-SELECTION *
************************************************************************
START-OF-SELECTION.
LOOP AT I_DATA INTO WA_DATA.
PERFORM BDC_DYNPRO USING 'SAPMJ3GJ' '0100'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ANTA'.
PERFORM BDC_DYNPRO USING 'SAPLV14A' '0100'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=WEIT'.
PERFORM BDC_DYNPRO USING 'SAPMJ3GJ' '1504'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=SICH'.
PERFORM BDC_FIELD USING 'J_3GKOMJ-EQUNR'
WA_DATA-EQUNR.
PERFORM BDC_FIELD USING 'J_3GKOMJ-J_3GLVART'
WA_DATA-J_3GLVART.
PERFORM BDC_FIELD USING 'J_3GKOMJ-J_3GBLTYP(01)'
WA_DATA-J_3GBLTYP1.
PERFORM BDC_FIELD USING 'J_3GKOMJ-J_3GBLTYP(02)'
WA_DATA-J_3GBLTYP2.
PERFORM BDC_FIELD USING 'J_3GPRLIST-PLTYP(01)'
WA_DATA-PLTYP1.
PERFORM BDC_FIELD USING 'J_3GPRLIST-PLTYP(02)'
WA_DATA-PLTYP2.
CALL TRANSACTION 'J4GD' USING I_BDCDATA MODE P_MODE UPDATE 'A' MESSAGES INTO I_MESSTAB.
REFRESH I_BDCDATA[].
ENDLOOP.
************************************************************************
*START-OF-SELECTION *
************************************************************************
END-OF-SELECTION.
LOOP AT I_MESSTAB INTO WA_MESSTAB.
CLEAR WF_MESSAGE.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = WA_MESSTAB-MSGID
LANG = SY-LANGU
NO = WA_MESSTAB-MSGNR
V1 = WA_MESSTAB-MSGV1
V2 = WA_MESSTAB-MSGV2
V3 = WA_MESSTAB-MSGV3
V4 = WA_MESSTAB-MSGV4
IMPORTING
MSG = WF_MESSAGE
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
WRITE / WF_MESSAGE .
ENDLOOP.
ULINE.
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM TYPE ANY
FVAL TYPE ANY.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_FIELD
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR WA_BDCDATA.
WA_BDCDATA-PROGRAM = PROGRAM.
WA_BDCDATA-DYNPRO = DYNPRO.
WA_BDCDATA-DYNBEGIN = 'X'.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_DYNPRO
No comments:
Post a Comment