report ZSJ_GL_UPLOAD
no standard page heading line-size 255.
DATA :IT_MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
DATA : BDCDATA TYPE BDCDATA OCCURS 0 WITH HEADER LINE.
DATA : IDX LIKE SY-TABIX.
DATA : BEGIN OF ITAB OCCURS 0 ,
BLDAT(10) TYPE C , " LIKE BKPF-BLDAT,
BLART(2) TYPE C , "LIKE BKPF-BLART,
BUKRS(4) TYPE C, "LIKE BKPF-BUKRS,
BUDAT(10) TYPE C,
MONAT(2) TYPE C,
WAERS(3) TYPE C,
BKTXT(25) TYPE C,
NEWBS(2) TYPE C , "LIKE RF05A-NEWBS,
NEWKO(17) TYPE C , "LIKE RF05A-NEWKO,
WRBTR(13) TYPE C, " LIKE BSEG-WRBTR,
VALUT(10) TYPE C,
ZUONR(25) TYPE C,
SGTXT(25) TYPE C,
GSBER(4) TYPE C , " LIKE COBL-GSBER,
PRCTR(10) TYPE C , "LIKE COBL-PRCTR,
MATNR(20) TYPE C,
END OF ITAB .
*----------------------------------------------------------------------*
SELECTION-SCREEN : BEGIN OF BLOCK BL1 WITH FRAME TITLE TEXT-001.
PARAMETER : P_IFILE TYPE STRING , " LIKE RLGRAP-FILENAME OBLIGATORY,
GRPID LIKE APQI-GROUPID OBLIGATORY.
SELECTION-SCREEN : END OF BLOCK BL1.
*----------------------------------------------------------------------*
* At Selection-screen *
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_IFILE.
PERFORM F4_HELP_P_FILE.
START-OF-SELECTION.
PERFORM GUI_UPLOAD.
PERFORM BDC_OPEN_GROUP.
PERFORM SESSION_METHOD .
PERFORM CLOSE_GROUP.
*&---------------------------------------------------------------------*
*& Form F4_HELP_P_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM F4_HELP_P_FILE .
DATA : V_FILE(128) TYPE C . "LIKE P_FILE.
* Display popup with files list to select
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = V_FILE.
CHECK SY-SUBRC EQ 0.
P_IFILE = V_FILE.
ENDFORM. " F4_HELP_P_FILE
*&---------------------------------------------------------------------*
*& Form GUI_UPLOAD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GUI_UPLOAD .
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = P_IFILE
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* VIRUS_SCAN_PROFILE =
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
DATA_TAB = ITAB
* EXCEPTIONS
* FILE_OPEN_ERROR = 1
* FILE_READ_ERROR = 2
* NO_BATCH = 3
* GUI_REFUSE_FILETRANSFER = 4
* INVALID_TYPE = 5
* NO_AUTHORITY = 6
* UNKNOWN_ERROR = 7
* BAD_DATA_FORMAT = 8
* HEADER_NOT_ALLOWED = 9
* SEPARATOR_NOT_ALLOWED = 10
* HEADER_TOO_LONG = 11
* UNKNOWN_DP_ERROR = 12
* ACCESS_DENIED = 13
* DP_OUT_OF_MEMORY = 14
* DISK_FULL = 15
* DP_TIMEOUT = 16
* OTHERS = 17
.
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. " GUI_UPLOAD
*&---------------------------------------------------------------------*
*& Form SESSION_METHOD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SESSION_METHOD .
LOOP AT ITAB .
* REFRESH BDCDATA.
* CLEAR BDCDATA.
IDX = SY-INDEX .
IDX = IDX + 1 .
*perform open_group.
perform bdc_dynpro using 'SAPMF05A' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RF05A-NEWKO'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BKPF-BLDAT' ITAB-BLDAT.
* '19.12.2008'.
perform bdc_field using 'BKPF-BLART' ITAB-BLART.
* 'JV'.
perform bdc_field using 'BKPF-BUKRS' ITAB-BUKRS.
* 'TCIL'.
perform bdc_field using 'BKPF-BUDAT' ITAB-BUDAT.
* '19.12.2008'.
perform bdc_field using 'BKPF-MONAT' ITAB-MONAT.
* '12'.
perform bdc_field using 'BKPF-WAERS' ITAB-WAERS.
* 'INR'.
perform bdc_field using 'BKPF-BKTXT' ITAB-BKTXT.
* 'TRANSFER'.
perform bdc_field using 'FS006-DOCID'
'*'.
perform bdc_field using 'RF05A-NEWBS' ITAB-NEWBS.
* '40'.
perform bdc_field using 'RF05A-NEWKO' ITAB-NEWKO.
* '99999964'.
perform bdc_dynpro using 'SAPMF05A' '0300'.
perform bdc_field using 'BDC_CURSOR'
'RF05A-NEWKO'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BSEG-WRBTR' ITAB-WRBTR.
* '100'.
perform bdc_field using 'BSEG-VALUT' ITAB-VALUT.
* '19.12.2008'.
perform bdc_field using 'BSEG-ZUONR' ITAB-ZUONR.
* 'TRANSFER'.
perform bdc_field using 'BSEG-SGTXT' ITAB-SGTXT.
* 'TRANSFER'.
DELETE ITAB INDEX IDX.
CLEAR :ITAB.
READ TABLE ITAB .
perform bdc_field using 'RF05A-NEWBS' ITAB-NEWBS .
* '50'.
perform bdc_field using 'RF05A-NEWKO' ITAB-NEWKO.
* '99999964'.
perform bdc_dynpro using 'SAPLKACB' '0002'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
perform bdc_field using 'COBL-GSBER' ITAB-GSBER.
* 'TMMG'.
perform bdc_field using 'COBL-PRCTR' ITAB-PRCTR.
* 'TM0001'.
perform bdc_field using 'COBL-MATNR' ITAB-MATNR .
* 'DUMMY'.
perform bdc_dynpro using 'SAPMF05A' '0300'.
perform bdc_field using 'BDC_CURSOR'
'BSEG-SGTXT'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'BSEG-WRBTR' ITAB-WRBTR.
* '100'.
perform bdc_field using 'BSEG-VALUT' ITAB-VALUT.
* '19.12.2008'.
perform bdc_field using 'BSEG-ZUONR' ITAB-ZUONR.
* 'TRANSFER'.
perform bdc_field using 'BSEG-SGTXT' ITAB-SGTXT.
* 'TRANSFER'.
perform bdc_dynpro using 'SAPLKACB' '0002'.
perform bdc_field using 'BDC_CURSOR'
'COBL-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
perform bdc_field using 'COBL-GSBER' ITAB-GSBER .
* 'tmmg'.
perform bdc_field using 'COBL-PRCTR' ITAB-PRCTR.
* 'tm0001'.
perform bdc_field using 'COBL-MATNR' ITAB-MATNR .
* 'dummy'.
*perform bdc_transaction using 'F-02'.
PERFORM BDC_INSERT.
* CLEAR : BDCDATA .
DELETE ITAB INDEX IDX.
CLEAR :ITAB.
READ TABLE ITAB .
ENDLOOP.
PERFORM BDC_CLOSE.
IF SY-SUBRC EQ 0.
WRITE:/ 'SESSION CREATED'.
ELSE.
WRITE:/ 'SESSION NOT CREATED, ERRORS OCCURED'.
ENDIF.
*perform close_group.
ENDFORM. " SESSION_METHOD
*&---------------------------------------------------------------------*
*& Form CLOSE_GROUP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CLOSE_GROUP .
ENDFORM. " CLOSE_GROUP
*&---------------------------------------------------------------------*
*& Form BDC_INSERT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BDC_INSERT .
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'F-02'
TABLES
DYNPROTAB = BDCDATA
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN = 2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 6
OTHERS = 7
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
REFRESH BDCDATA.
ENDFORM. " BDC_INSERT
*&---------------------------------------------------------------------*
*& Form BDC_CLOSE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BDC_CLOSE .
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* CALL FUNCTION 'BDC_CLOSE_GROUP'
.
ENDFORM. " BDC_CLOSE
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM. "BDC_DYNPRO
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
* IF FVAL <> NODATA.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
* ENDIF.
ENDFORM. "BDC_FIELD
*&---------------------------------------------------------------------*
*& Form BDC_OPEN_GROUP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BDC_OPEN_GROUP .
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = GRPID
KEEP = 'X'
USER = SY-UNAME
* IMPORTING
* QID =
EXCEPTIONS
CLIENT_INVALID = 1
DESTINATION_INVALID = 2
GROUP_INVALID = 3
GROUP_IS_LOCKED = 4
HOLDDATE_INVALID = 5
INTERNAL_ERROR = 6
QUEUE_ERROR = 7
RUNNING = 8
SYSTEM_LOCK_ERROR = 9
USER_INVALID = 10
OTHERS = 11
.
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. " BDC_OPEN_GROUP
No comments:
Post a Comment