‎2007 Nov 01 2:25 AM
Hello All,
I have a question in BDC session method. I am using BDC insert for calling ME11, ME12 and ME15 (create, change and delete) transaction for creating purchase info records. I have a specific situation where I am looping thru an internal table and calling BDC_insert (Create, change or delete) for each record . Finally, after looping all records, submitting 'rsbdcsub' program to release the bdc sessions. Only the first record in the internal table is committed and all others are ignored. Why is this happening? Do I need to explicitly call BDC_release after every insert.
I cannot release the session until the entire records are successfully inserted. So please suggest some solution for achieving this
Thanks
Ricky
‎2007 Nov 01 2:36 AM
‎2007 Nov 01 5:43 AM
Hi All,
Here is the code.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
client = sy-mandt
DEST = FILLER8
group = l_group
HOLDDATE = FILLER8
keep = 'X'
user = sy-uname
RECORD = FILLER1
PROG = SY-CPROG
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
.
itab is an internal table which contain the input data to be processed.
wa_tab is a work area.
Loop at itab into wa_tab.
if wa_tab-flag = 'A'. "Create info record
PERFORM bdc_dynpro_start USING 'SAPMM06I' '0100'.
PERFORM bdc_insert_field. "This is recording program to create info record
call function bdc_insert
exporting
tcode = ME11
tables
dynprotab = t_bdc_table.
elseif wa_tab-flag = 'C'. "Change info record
PERFORM bdc_dynpro_start USING 'SAPMM06I' '0100'.
PERFORM bdc_insert_field. "This is recording program to change info record
call function bdc_insert
exporting
tcode = ME12
tables
dynprotab = t_bdc_table.
else. "Delete info record
PERFORM bdc_dynpro_start USING 'SAPMM06I' '0100'.
PERFORM bdc_insert_field. "This is recording program to delete info record
call function bdc_insert
exporting
tcode = ME15
tables
dynprotab = t_bdc_table.
Endloop.
FORM bdc_insert_field USING f_name f_value.
IF f_value <> space.
CLEAR t_bdc_table.
t_bdc_table-fnam = f_name.
t_bdc_table-fval = f_value.
APPEND t_bdc_table.
ENDIF.
ENDFORM. "bdc_insert_field
form bdc_dynpro_start using p_g_program_1
p_g_screen.
CLEAR t_bdc_table.
t_bdc_table-program = p_g_program_1.
t_bdc_table-dynpro = p_g_screen.
t_bdc_table-dynbegin = 'X'.
APPEND t_bdc_table.
endform. " bdc_dynpro_start
Call function bdc_close_group.
SUBMIT rsbdcsub WITH mappe EQ l_group
WITH von EQ sy-datum
WITH bis EQ sy-datum
WITH fehler EQ '.'
EXPORTING LIST TO MEMORY
AND RETURN.
I want to call this submit only once in the program and if all records are successfully processed. Otherwise, I need to delete the session to give it a roll back.
Hope it is clear now. Any other approach is also welcomed. Thanks!
Thanks
Ricky
‎2007 Nov 01 6:26 AM
‎2007 Nov 01 6:31 AM
‎2007 Nov 01 6:33 AM
‎2007 Nov 01 7:04 AM
Thanks guys. It's working now with the same code. There was some typo error.
I hve one last question. If one of the records error out, I have to basically roll-back the entire records. So I won't be calling the release session program. Is there any other way to roll back after BDC_close_group call.
Thanks