‎2007 Oct 31 3:11 PM
Hi Experts,
i had recorded one transaction in SHDB tcode after that through that tcode i cretaed one FM up to this fine. The FM is working fine also but after excution of that its opening as many as possible new sessions , so how to handle this situtation, please help me i will reward for helpful answers.
‎2007 Oct 31 3:15 PM
Have you used open_group FM within loop then it creates many sessions.
Use open_group before loop at int_table
Thanks
Seshu
‎2007 Oct 31 3:32 PM
Hi Sheshu,
i am not using any loop in that FM , i recorded just as it is i am running with out change any soruce code,
‎2007 Oct 31 3:39 PM
May be your FM is being called in the loop.
Check the FM.. in SE37, you will find that the FM is opening one session and closing the session .....
Remove from the FM ..
perform open_group using GROUP USER KEEP HOLDDATE CTU.
perform close_group using CTU.
Open your session before the FM call and close the session after FM call.
Regards,
Naimesh Patel.
‎2007 Oct 31 3:44 PM
Steps for BDC Session .
1st step - Get the data from file to internal table
2nd step - build the internal table propely
3rd step - call BDC_OPEN_GROUP FM
4th Step :
Loop ur internal table.
fill the bdc ok codes
call bdc_insert.
refresh i_bdcdata
endloop.
call bdc_close_group FM.
Check the below program for your reference :
report ztest_bdc.
data:v_repid like sy-repid,
v_file type string.
data : begin of i_text occurs 0,
text(1024) type c,
end of i_text.
data : begin of i_mm01 occurs 0,
matnr(10) type c,
mbrsh(1) type c,
mtart(4) type c,
maktx(20) type c,
meins(3) type c,
matkl(2) type c,
end of i_mm01.
data i_bdcdata like bdcdata occurs 0 with header line.
parameters p_file like rlgrap-filename.
initialization.
v_repid = sy-repid.
at selection-screen on value-request for p_file.
call function 'F4_FILENAME'
exporting
program_name = v_repid
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
importing
file_name = p_file.
start-of-selection.
*getting the data from file to internal table
perform get_data.
&----
*& Form get_data
&----
text
----
--> p1 text
<-- p2 text
----
form get_data .
v_file = p_file.
call function 'GUI_UPLOAD'
exporting
filename = v_file
filetype = 'ASC'
HAS_FIELD_SEPARATOR = ' '
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 = i_text
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.
else.
loop at i_text.
split i_text-text at ',' into i_mm01-matnr
i_mm01-mbrsh
i_mm01-mtart
i_mm01-maktx
i_mm01-meins
i_mm01-matkl.
append i_mm01.
clear: i_text,
i_mm01.
endloop.
endif.
loop at i_mm01.
write:/ i_mm01-matnr,i_mm01-mbrsh, i_mm01-mtart, i_mm01-maktx,
i_mm01-meins,i_mm01-matkl.
endloop.
endform. " get_data
end-of-selection.
call function 'BDC_OPEN_GROUP'
exporting
client = sy-mandt
DEST = FILLER8
group = 'session2'
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
.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
**********************************************************************************
populating i_bdcdata
**********************************************************************************
loop at i_mm01.
*first screen
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RMMG1-MATNR'
i_mm01-matnr.
perform bdc_field using 'RMMG1-MBRSH'
i_mm01-mbrsh.
perform bdc_field using 'RMMG1-MTART'
i_mm01-mtart.
second screen
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
'X'.
third screen
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'MAKT-MAKTX'
i_mm01-maktx.
perform bdc_field using 'BDC_CURSOR'
'MARA-MATKL'.
perform bdc_field using 'MARA-MEINS'
i_mm01-meins.
perform bdc_field using 'MARA-MATKL'
i_mm01-matkl.
call function 'BDC_INSERT'
exporting
tcode = 'MM01'
POST_LOCAL = NOVBLOCAL
PRINTING = NOPRINT
SIMUBATCH = ' '
CTUPARAMS = ' '
tables
dynprotab = i_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 i_bdcdata.
endloop.
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.
&----
*& Form bdc_dynpro
&----
text
----
form bdc_dynpro using p_prog
p_scrn.
clear i_bdcdata.
i_bdcdata-program = p_prog.
i_bdcdata-dynpro = p_scrn.
i_bdcdata-dynbegin = 'X'.
append i_bdcdata.
endform. " bdc_dynpro
&----
*& Form bdc_field
&----
text
----
form bdc_field using p_fnam
p_fval.
clear i_bdcdata.
i_bdcdata-fnam = p_fnam.
i_bdcdata-fval = p_fval.
append i_bdcdata.
endform. " bdc_field
Thanks
Seshu