report ZBDC_ME38
no standard page heading line-size 255.
*include bdcrecx1.
*parameters: dataset(132) lower case.
*** DO NOT CHANGE - the generated data section - DO NOT CHANGE ***
*
* If it is nessesary to change the data section use the rules:
* 1.) Each definition of a field exists of two lines
* 2.) The first line shows exactly the comment
* '* data element: ' followed with the data element
* which describes the field.
* If you don't have a data element use the
* comment without a data element name
* 3.) The second line shows the fieldname of the
* structure, the fieldname must consist of
* a fieldname and optional the character '_' and
* three numbers and the field length in brackets
* 4.) Each field must be type C.
*
*** Generated data section with specific formatting - DO NOT CHANGE ***
DATA: file_path TYPE string.
DATA: I_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
*
data: begin of record OCCURS 0,
EVRTN_001(010),
EBELP_002(005),
ETNR1_003(004),
LPEIN_04_004(001),
EEIND_04_005(010),
MENGE_04_006(017),
end of record.
START-OF-SELECTION.
SELECTION-SCREEN BEGIN OF BLOCK mode WITH FRAME TITLE text-003.
PARAMETERS: file_url TYPE rlgrap-filename MODIF ID xyz .
SELECTION-SCREEN END OF BLOCK mode .
*PARAMETERS: dataset(132) lower case.
*perform open_dataset using dataset.
*Uploading data from the local file C:\MSchedule.txt
*CALL FUNCTION 'WS_UPLOAD'
* EXPORTING
* FILENAME = 'C:\MSCHEDULE.TXT'
* FILETYPE = 'DAT'
* TABLES
* data_tab = I_BDCDATA .
*
*IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR file_url.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = 'FILE_URL'
IMPORTING
file_name = file_url.
start-of-selection.
IF NOT file_url IS INITIAL.
MOVE file_url TO file_path.
PERFORM read_file.
ENDIF.
perform open_group.
perform close_group. "Closing the BDC session
LOOP AT RECORD. "Filling the BDC table with data
*read dataset dataset into record.
perform bdc_dynpro using 'SAPMM06E' '0205'.
perform bdc_field using 'BDC_CURSOR'
'RM06E-EVRTN'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RM06E-EVRTN'
record-EVRTN_001.
perform bdc_dynpro using 'SAPMM06E' '0222'.
perform bdc_field using 'BDC_CURSOR'
'EKPO-EMATN(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ET'.
perform bdc_field using 'RM06E-EBELP'
record-EBELP_002.
perform bdc_dynpro using 'SAPMM06E' '1117'.
perform bdc_field using 'BDC_CURSOR'
'EKET-MENGE(04)'.
perform bdc_field using 'BDC_OKCODE'
'BU'.
perform bdc_field using 'RM06E-ETNR1'
record-ETNR1_003.
perform bdc_field using 'RM06E-LPEIN(04)'
record-LPEIN_04_004.
perform bdc_field using 'RM06E-EEIND(04)'
record-EEIND_04_005.
perform bdc_field using 'EKET-MENGE(04)'
record-MENGE_04_006.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
perform bdc_transaction using 'ME38'.
ENDLOOP.
FORM read_file .
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file_path
filetype = 'ASC'
has_field_separator = 'X'
* HEADER_LENGTH = 0
read_by_line = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = record
* 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. " read_file
*perform close_dataset using dataset.
FORM OPEN_GROUP.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = 'SESSION1'
USER = SY-UNAME
KEEP = 'X'.
IF SY-SUBRC <> 0.
WRITE 'ERROR IN OPEN_GROUP'.
ENDIF.
ENDFORM.
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.
FORM BDC_FIELD USING FNAM FVAL.
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = FNAM.
I_BDCDATA-FVAL = FVAL.
APPEND I_BDCDATA.
ENDFORM.
FORM BDC_TRANSACTION USING TCODE.
CALL FUNCTION 'BDC_INSERT'
EXPORTING TCODE = TCODE
TABLES DYNPROTAB = I_BDCDATA.
ENDFORM.
FORM CLOSE_GROUP.
CALL FUNCTION 'BDC_CLOSE_GROUP'.
ENDFORM. " CLOSE_GROUP
↧
devoloping the BDC For material schedule update for me38 but gives the error :-BDC_INSERT, session not opened
↧