Barış Batch Içinzbdcrecx1include

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

***INCLUDE ZBDCRECX1.

* for programs doing a data transfer by creating a batch-input session

parameters group(12) obligatory.


parameters: user(12) default sy-uname obligatory.
parameters: keep as checkbox default 'X'.
parameters: fname like ibipparms-path obligatory.

*----------------------------------------------------------------------*
* data definition
*----------------------------------------------------------------------*
* Batchinputdata of single transaction
data: bdcdata like bdcdata occurs 0 with header line.
* messages of call transaction
data: messtab like bdcmsgcoll occurs 0 with header line.
* error session opened (' ' or 'X')
data: e_group_opened.
* message texts
tables: t100.

at selection-screen on value-request for fname.


call function 'F4_FILENAME'
importing
file_name = fname.

*----------------------------------------------------------------------*
* open dataset *
*----------------------------------------------------------------------*
form open_dataset using p_dataset.
open dataset p_dataset in text mode.
if sy-subrc <> 0.
write: / text-e00, sy-subrc.
stop.
endif.
endform.

*----------------------------------------------------------------------*
* close dataset *
*----------------------------------------------------------------------*
form close_dataset using p_dataset.
close dataset p_dataset.
endform.

*----------------------------------------------------------------------*
* create batchinput session *
* (not for call transaction using...) *
*----------------------------------------------------------------------*
form open_group.

write: /(20) 'Create group'(i01), group.


* open batchinput group
call function 'BDC_OPEN_GROUP'
exporting
client = sy-mandt
group = group
user = user
keep = keep.
write: /(30) 'BDC_OPEN_GROUP'(i02),
(12) 'returncode:'(i05),
sy-subrc.
endform.

*----------------------------------------------------------------------*
* end batchinput session *
* (call transaction using...: error session) *
*----------------------------------------------------------------------*
form close_group.

* close batchinput group


call function 'BDC_CLOSE_GROUP'.
write: /(30) 'BDC_CLOSE_GROUP'(i04),
(12) 'returncode:'(i05),
sy-subrc.
endform.

*----------------------------------------------------------------------*
* Start new transaction according to parameters *
*----------------------------------------------------------------------*
form bdc_transaction using tcode.
* batch input session
call function 'BDC_INSERT'
exporting
tcode = tcode
tables
dynprotab = bdcdata.
refresh bdcdata.
endform.

*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
form bdc_dynpro using program dynpro.
clear bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
append bdcdata.
endform.

*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
form bdc_field using fnam fval.
clear bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
append bdcdata.
endform.

You might also like