REPORT ZETM_BDC_J3G$.
************************************************************************
*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,
DATUM(10) TYPE C,
J_3GEMPFAE TYPE J_3GEMPFAE,
POSID TYPE PS_POSID,
EQUNR1 TYPE EQUNR,
J_3GLVART1 TYPE J_3GLVART,
J_3GMENGE1(8),
END OF TYPE_DATA.
************************************************************************
*WORK AREA DECLARATION *
************************************************************************
DATA : WA_BDCDATA TYPE TYPE_BDCDATA,
WA_DATA TYPE TYPE_DATA,
WA_DATA1 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),
WF_CTR(3),
WF_CTR1(3),
WF_CTR2(3),
WF_FNAM TYPE FNAM_____4,
WF_COUNT(4),
WF_DATE TYPE DATUM,
WF_FLAG.
************************************************************************
*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_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.
CLEAR WA_DATA1.
WA_DATA1 = WA_DATA.
AT NEW J_3GEMPFAE.
CLEAR : WF_CTR, WF_CTR1, WF_CTR2, WF_COUNT, WF_DATE, WF_FLAG.
WF_DATE+0(1) = WA_DATA1-DATUM+6(1).
WF_DATE+1(1) = WA_DATA1-DATUM+7(1).
WF_DATE+2(1) = WA_DATA1-DATUM+8(1).
WF_DATE+3(1) = WA_DATA1-DATUM+9(1).
WF_DATE+4(1) = WA_DATA1-DATUM+3(1).
WF_DATE+5(1) = WA_DATA1-DATUM+4(1).
WF_DATE+6(1) = WA_DATA1-DATUM+0(1).
WF_DATE+7(1) = WA_DATA1-DATUM+1(1).
SELECT COUNT( * ) FROM J_3GBELP INTO WF_COUNT
WHERE J_3GBELNRI GE '4500000000'
AND J_3GBELNRI LE '4599999999'
AND J_3GUPOSNR EQ '01'
AND J_3GEMPFAE EQ WA_DATA1-J_3GEMPFAE
AND J_3GDATLAB EQ WF_DATE.
IF SY-SUBRC = 0.
WF_FLAG = 'X'.
ENDIF.
WF_CTR1 = 1.
PERFORM BDC_DYNPRO USING 'SAPMJ3GI' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
PERFORM BDC_FIELD USING 'J_3GBELK-J_3GBLART'
'P1'.
PERFORM BDC_DYNPRO USING 'SAPMJ3GI' '1000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'DATUM'
WA_DATA1-DATUM.
PERFORM BDC_FIELD USING 'J_3GBELK-J_3GEMPFAE'
WA_DATA1-J_3GEMPFAE.
IF NOT WA_DATA1-POSID IS INITIAL.
PERFORM BDC_DYNPRO USING 'SAPMSSY0' '0120'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'02/03'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=NSEL'.
PERFORM BDC_DYNPRO USING 'SAPLSDH4' '0200'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=GOON'.
PERFORM BDC_FIELD USING 'G_SELFLD_TAB-LOW(01)'
WA_DATA1-POSID.
PERFORM BDC_DYNPRO USING 'SAPMSSY0' '0120'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
ENDIF.
ENDAT.
IF WF_FLAG = 'X'.
PERFORM BDC_DYNPRO USING 'SAPMJ3GI' '1000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'SCREEN_TOP_LINE'
WF_COUNT.
WF_CTR = 1.
CLEAR WF_FLAG.
ENDIF.
WF_CTR = WF_CTR + 1.
WF_CTR2 = WF_CTR.
IF WF_CTR > 13.
WF_CTR1 = WF_CTR1 + 1.
PERFORM BDC_DYNPRO USING 'SAPMJ3GI' '1000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'SCREEN_TOP_LINE'
WF_CTR1.
WF_CTR2 = '13'.
ENDIF.
PERFORM BDC_DYNPRO USING 'SAPMJ3GI' '1000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
CLEAR WF_FNAM.
CONCATENATE 'XMATRIX-EQUNR(' WF_CTR2 ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-EQUNR1.
CLEAR WF_FNAM.
CONCATENATE 'XMATRIX-J_3GLVART(' WF_CTR2 ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-J_3GLVART1.
PERFORM BDC_DYNPRO USING 'SAPMJ3GI' '1000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
CLEAR WF_FNAM.
CONCATENATE 'XMATRIX-MENGE_1(' WF_CTR2 ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-J_3GMENGE1.
CLEAR WF_FNAM.
CONCATENATE 'XMATRIX-MENGE_2(' WF_CTR2 ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-J_3GMENGE1.
CLEAR WF_FNAM.
CONCATENATE 'XMATRIX-MENGE_3(' WF_CTR2 ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-J_3GMENGE1.
CLEAR WF_FNAM.
CONCATENATE 'XMATRIX-MENGE_4(' WF_CTR2 ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-J_3GMENGE1.
CLEAR WF_FNAM.
CONCATENATE 'XMATRIX-MENGE_5(' WF_CTR2 ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-J_3GMENGE1.
CLEAR WF_FNAM.
CONCATENATE 'XMATRIX-MENGE_6(' WF_CTR2 ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-J_3GMENGE1.
CLEAR WF_FNAM.
CONCATENATE 'XMATRIX-MENGE_7(' WF_CTR2 ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-J_3GMENGE1.
AT END OF J_3GEMPFAE.
PERFORM BDC_DYNPRO USING 'SAPMJ3GI' '1000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=SAVE'.
CALL TRANSACTION 'J3G$' USING I_BDCDATA MODE P_MODE UPDATE 'A' MESSAGES INTO I_MESSTAB.
REFRESH I_BDCDATA[].
ENDAT.
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
FVAL.
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