report ZHR_MMG_BDC_REPORTING_UPLOAD
no standard page heading line-size 255.
DATA: I_BDCDATA TYPE BDCDATA OCCURS 0 WITH HEADER LINE,
I_ERROR TYPE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
PARAMETERS: P_FILE TYPE RLGRAP-FILENAME OBLIGATORY,
P_MODE(1) DEFAULT 'A'.
SELECTION-SCREEN : BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.
PARAMETER: PBROW_HD TYPE I default 1, PEROW_HD TYPE I, PBCOL_HD TYPE i default 1, PECOL_HD TYPE I default 2.
SELECTION-SCREEN : END OF BLOCK BLK1.
DATA: T_EXCEL LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
DATA: BEGIN of record occurs 0,
SEARK(8),
SOBID(8),
end of record.
DATA: V_FILENAME LIKE RLGRAP-FILENAME.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = P_FILE.
START-OF-SELECTION.
PERFORM UPLOAD.
PERFORM BDC.
*&---------------------------------------------------------------------*
*& Form UPLOAD
*----------------------------------------------------------------------*
FORM UPLOAD .
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FILE
I_BEGIN_COL = PBCOL_HD
I_BEGIN_ROW = PBROW_HD
I_END_COL = PECOL_HD
I_END_ROW = PEROW_HD
TABLES
INTERN = T_EXCEL
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
LOOP AT T_EXCEL.
CASE T_EXCEL-COL.
WHEN 1. MOVE T_EXCEL-VALUE TO RECORD-SEARK.
WHEN 2. MOVE T_EXCEL-VALUE TO RECORD-SOBID.
ENDCASE.
AT END OF ROW.
APPEND RECORD.
CLEAR RECORD.
ENDAT.
ENDLOOP.
ENDFORM. " UPLOAD
*&---------------------------------------------------------------------*
*& Form BDC
*----------------------------------------------------------------------*
FORM BDC .
loop at record.
perform bdc_dynpro using 'SAPMH5A0' '5100'.
perform bdc_field using 'BDC_CURSOR'
'PM0D1-SEARK'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'PPHDR-PLVAR'
'01'.
perform bdc_field using 'PM0D1-SEARK'
record-seark. " '50000287'.
perform bdc_field using 'PM0D1-TIMR6'
'X'.
perform bdc_field using 'PPHDR-BEGDA'
'07.07.2010'.
perform bdc_field using 'PPHDR-ENDDA'
'31.12.9999'.
perform bdc_dynpro using 'SAPMH5A0' '5100'.
perform bdc_field using 'BDC_OKCODE'
'=INSE'.
perform bdc_field using 'PPHDR-PLVAR'
'01'.
perform bdc_field using 'PM0D1-SEARK'
record-seark."'50000287'.
perform bdc_field using 'BDC_CURSOR'
'PPHDR-BEGDA'.
perform bdc_field using 'PM0D1-TIMR6'
'X'.
perform bdc_field using 'PPHDR-BEGDA'
'01.07.2010'.
perform bdc_field using 'PPHDR-ENDDA'
'31.12.9999'.
perform bdc_field using 'MARKFELD(02)'
'X'.
perform bdc_dynpro using 'MP100100' '2000'.
perform bdc_field using 'BDC_CURSOR'
'P1001-SOBID'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'P1001-BEGDA'
'01.07.2010'.
perform bdc_field using 'P1001-ENDDA'
'31.12.9999'.
perform bdc_field using 'P1001-RSIGN'
'a'.
perform bdc_field using 'P1001-RELAT'
'002'.
perform bdc_field using 'P1001-SCLAS'
'S'.
perform bdc_field using 'P1001-SOBID'
record-sobid."'50000288'.
perform bdc_dynpro using 'MP100100' '2000'.
perform bdc_field using 'BDC_CURSOR'
'P1001-BEGDA'.
perform bdc_field using 'BDC_OKCODE'
'=UPD'.
perform bdc_field using 'P1001-BEGDA'
'01.07.2010'.
perform bdc_field using 'P1001-ENDDA'
'31.12.9999'.
perform bdc_field using 'P1001-RSIGN'
'A'.
perform bdc_field using 'P1001-RELAT'
'002'.
perform bdc_field using 'P1001-SCLAS'
'S'.
perform bdc_field using 'P1001-SOBID'
record-sobid."'50000288'.
perform bdc_dynpro using 'SAPMH5A0' '5100'.
perform bdc_field using 'BDC_OKCODE'
'=BACK'.
perform bdc_field using 'PPHDR-PLVAR'
'01'.
perform bdc_field using 'PM0D1-SEARK'
record-seark."'50000287'.
*perform bdc_transaction using 'PO13'.
CALL TRANSACTION 'PO13' USING I_BDCDATA MODE P_MODE.
CLEAR I_BDCDATA[].
endloop.
ENDFORM. " BDC
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR I_BDCDATA.
I_BDCDATA-PROGRAM = PROGRAM.
I_BDCDATA-DYNPRO = DYNPRO.
I_BDCDATA-DYNBEGIN = 'X'.
APPEND I_BDCDATA.
ENDFORM. "bdc_dynpro
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = FNAM.
I_BDCDATA-FVAL = FVAL.
APPEND I_BDCDATA.
ENDFORM.
No comments:
Post a Comment