Program To Update BDC Session Status in SM35
Existing Process : Currently we create orders using a function module which internally uses BDC Session method for transaction VA01. If the session ran successfully then we check the status and use SAVE_TEXT to upload the long text for the order. But in some cases the order fails. Then the session will be errored out in SM35 and user runs the session manually and fixes the problem and post order. So the text cannot be uploaded now as the user ran the session manually. So I wrote a Z program to run the session using program RSBDCCTU which the runs the session in forground and get the text from memory which I exported to memory while initial transaction and upload it using SAVE_TEXT after the session ran successfully. This program works fine.
Problem : After running my Z program the order is posted and text is uploaded but the session is still in error status in SM35. The standard program RSBDCCTU just runs the session in foreground but does not update the status.
Is there any other way we can do this or any other standard programs available to update the status of the session.
Any help will be appreciated.
How are you importing text in the z program, which is exported in the function module? they are totally unrelated internal sessions.
You can as well import text and use SAVE_TEXT using user exit USEREXIT_SAVE_DOCUMENT_PREPARE in include MV45AFZZ after executing the error session in SM35, you don't need a Z program.
Use condition SY-BINPT = 'X' and T180-TRTYP = 'H' in the user exit to process SAVE_TEXT.
Regards
Sridhar
Similar Messages
-
BDC Session processing in SM35
Hi,
Please let me if a session in SM35 has lot of data to process, will it be timed out??
Thanks & Regards,
Soumya.Hi Soumya
If you are not sure whether the huge data while processing would time out.
Follow these steps:-
1.Go to SM35.
2. Select the data to be processed.
3. Click the Process button. A pop will appear.
4. In Processing mode Select Background Radio button.
5. Also check the Extended log check button in additional functions.
Second way is:
1.Go to SM35.
2. Select the data to be processed.
3. Click the Process button. A pop will appear.
4. In Processing mode Select Display Errors Only Radio button.
5. It will process data in backgound and errors will appear in foreground. -
Storing of log file in A/P Server while running BDC session in SM35
Hi All,
I have issue when running BDC session in SM35.
The actual issue is
I need to store of log file generated while running BDC session in <b>SM35</b> in <b>Application/Presentation</b> Server path.
When ever we run single session the Log file regarding that session we need to store in Application/Presentation Server.
Can anybody have solution for this issue.
Thanks in advance.
Thanks & Regards,
Rayeez.Hi
See the std report RSBDC_ANALYSE, here you can know how to find out the log of B.I..
You can create a program like that to load the log into file instead of showing it.
Max -
Bdc session in status being created
Hi..
I have a custom program that creates bdc sessions. For some of the sessions it created, the status of the session is being created.
when i click on analysis of that session: it has
1 transaction with 8 screens in new
1 transaction with 8 screens in to process
1 transaction with 8 screens in current content
1 transaction with 8 screens in removed with - ve sign after 1 and 8.
0 transaction with 0 screens in (created, deleted, processed and incorrect)
Can someone tell me what might be the reason for the session to be in being created?
Appreciate your help and will reward helpful answers.
Thanks,
RKYes. As I said before thsi is because the BDC_CLOSE was not executed. You are seeign them as being created could be because soem was was tryign to debug the program and woudl have jumped out of the program half way. In this case the BDC_CLOSE would not have executed and the session will remain as 'Being created'. You dont have to worry abt it and it is purely because of partial execution of the program. You can try it on yoru own by gettign into the debugging mode and terminate the program after BDC_OPEN FM is executed. You will see another session with status beign created. The number of transaction in this session will depend on what point did you terminate the program.
- Guru
Reward points for helpful answers -
Updating a DB table by a BDC session in background
Hi,
I need to update a DB table with records using a BDC session. I need to run this session in background. But the Error Log I'm getting suggests that Table Maintenance is required for the same.
Note that I can very well insert records in this table thru se11 and also by running the session in foreground.
Is there any work-around for this issue?
Thanks.Hi
If at all you are using any DOWNLOAD and UPLOAD related function modules you can't run the BDC program in the background.
If it is a Z table update you can create the table maintenance generator.
other wise you can do it.
You can run session in background.
Reward points if useful
Regards
Anji -
What is BDC Session & Z-Program
Hi,
Can anyone tell me what is BDC Session & Z-Program ?
RajarshiDear Rajarshi,
BDC (Batch Data Communication) - is one of the methods for uploading the data. You have two options with BDC, namely Session and Call Transaction.
First you would record a particular transaction with SHDB simulating sample transaction entry. Then you would use this recording to create a 'Z' program.
With session method a session will be generated that needs to be processed in Transacton SM35 with Foreground, Background, or Errors only mode. You can view and analyze session log after processing the session.
With call transaction you would specify the mode in the program itself. Hence, no session is generated in SM35 in this case.
please visit the following link for more information:
http://help.sap.com/saphelp_erp2005/helpdata/en/fa/097119543b11d1898e0000e8322d00/frameset.htm
Z programs are custom programs. They could be reports, transactions, scripts, smartforms, BDCs, BAPIs etc. You would develop them if there is no SAP standard program available that meets your requirement.
Reward points if this is helpful.
Regards,
Naveen. -
Hi,
Please any body send a sample program for bdc session method.
Thanks,
sreedhar.See the BDC Session method program :
report zmppc011 no standard page heading line-size 120 line-count 55
message-id zz.
pool of form routines
include zmppn001.
Define BDC Table Structure
data: begin of itab_bdc_tab occurs 0.
include structure bdcdata.
data: end of itab_bdc_tab.
Input record layout of Leagcy File
data: begin of itab_xcel occurs 0,
matnr(18) type c,
werks(4) type c,
alnag(2) type c,
verid(4) type c,
text1(40) type c,
bstmi like mkal-bstmi,
bstma like mkal-bstma,
adatu(10) type c,
bdatu(10) type c,
stlal(2) type c,
stlan(1) type c,
serkz(1) type c,
mdv01(8) type c,
elpro(4) type c,
alort(4) type c,
end of itab_xcel.
data: begin of lt_pp04_cache occurs 0,
matnr like itab_xcel-matnr,
werks like itab_xcel-werks,
alnag like itab_xcel-alnag,
plnnr like mapl-plnnr,
arbpl like crhd-arbpl,
ktext like crtx-ktext,
end of lt_pp04_cache.
data: v_ssnnr(4) type n,
v_lines_in_xcel like sy-tabix,
v_ssnname like apqi-groupid,
v_trans_in_ssn type i,
wa_xcel LIKE itab_xcel,
l_tabix like sy-tabix,
v_matnr like rc27m-matnr,
v_plnnr like mapl-plnnr,
v_plnal like mapl-plnal,
v_tcode like sy-tcode value 'C223',
v_plnty like plas-plnty value 'R',
v_objty like crhd-objty value 'A',
v_plpo_steus like plpo-steus value 'PP04',
v_verwe like crhd-verwe value '0007'.
Parameters
selection-screen: skip 3.
selection-screen: begin of block 1 with frame.
parameters: p_name like rlgrap-filename
default 'C:\My Documents\InputFile.txt'
obligatory,
bdc session name prefix
p_bdcpfx(6) default 'ZPVCRT'
obligatory,
number for transction per BDC session
p_trnssn type i
default 2000 obligatory,
retain the BDC session after successfull execution
p_keep like apqi-qerase
default 'X',
user who will be executing BDC session
p_uname like apqi-userid
default sy-uname
obligatory.
selection-screen: end of block 1.
possible entry list (F4 dropdown) for input file name
at selection-screen on value-request for p_name.
*-SELECT FILE FROM USERS LOCAL PC
call function 'WS_FILENAME_GET'
exporting
DEF_FILENAME = ' '
def_path = 'C:\Temp\'
mask = ',.,..'
mode = 'O'
title = 'Select File '(007)
importing
filename = p_name
RC =
exceptions
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
others = 5.
if sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
begin the show
start-of-selection.
read data from input file
perform transfer_xcel_to_itab.
loop at itab_xcel.
hang on to xcel line num
l_tabix = sy-tabix.
each line in the xcel file marks begining of new prod.version defn
if num-of-trnas-in-session = 0, create new BDC session
if v_trans_in_ssn is initial.
perform bdc_session_open.
endif.
begin new bdc script for rtg create trans
fill in bdc-data for prod.version maintenance screens
perform bdc_build_script.
insert the bdc script as a BDC transaction
perform bdc_submit_transaction.
keep track of how many BDC transactions were inserted in the BDC
session
add 1 to v_trans_in_ssn.
if the user-specified num of trans in BDC session is reached OR
if end of input file is reached, close the BDC session
if v_trans_in_ssn = p_trnssn or
l_tabix = v_lines_in_xcel.
perform bdc_session_close.
clear v_trans_in_ssn.
endif.
endloop.
top-of-page.
call function 'Z_HEADER'
EXPORTING
FLEX_TEXT1 =
FLEX_TEXT2 =
FLEX_TEXT3 =
FORM TRANSFER_XCEL_TO_ITAB *
Transfer Xcel Spreadsheet to SAP Internal Table *
form transfer_xcel_to_itab.
Read the tab-delimited file into itab
call function 'WS_UPLOAD'
exporting
filename = p_name
filetype = 'DAT'
IMPORTING
filelength = flength
tables
data_tab = itab_xcel
exceptions
conversion_error = 1
file_open_error = 2
file_read_error = 3
invalid_table_width = 4
invalid_type = 5
no_batch = 6
unknown_error = 7
others = 8.
if sy-subrc = 0.
sort the data
sort itab_xcel by matnr werks.
clear v_lines_in_xcel.
if no data in the file - error out
describe table itab_xcel lines v_lines_in_xcel.
if v_lines_in_xcel is initial.
write: / 'No data in input file'.
stop.
endif.
else.
if file upload failed - error out
write: / 'Error reading input file'.
stop.
endif.
endform.
FORM BDC_SESSION_OPEN *
Open BDC Session *
form bdc_session_open.
create bdc session name = prefix-from-selectn-screen + nnnn
add 1 to v_ssnnr.
concatenate p_bdcpfx v_ssnnr into v_ssnname.
open new bdc session
call function 'BDC_OPEN_GROUP'
exporting
client = sy-mandt
group = v_ssnname
keep = p_keep
user = p_uname
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.
endform.
FORM BDC_BUILD_SCRIPT *
Build BDC *
form bdc_build_script.
data: l_arbpl like crhd-arbpl,
l_text1 like mkal-text1,
l_mdv01 like mkal-mdv01,
l_mapl like mapl.
clear bdc-data itab - begin of new bdc transaction
clear itab_bdc_tab.
refresh itab_bdc_tab.
read material cross reference tables to determine sap part#
clear : v_matnr, v_plnnr, v_plnal.
perform read_matnr_cross_ref using itab_xcel-matnr
itab_xcel-werks
changing v_matnr.
determine the version description to use
if itab_xcel-text1 is initial.
l_text1 = itab_xcel-verid.
else.
l_text1 = itab_xcel-text1.
endif.
determine the routing group# and group ctr# to use
perform read_routing .
determine the production line to use
if itab_xcel-mdv01 is initial.
if not provided in the file then:
prod line = work ctr on the last PP04 op of the rtg determined above
perform read_wc_on_last_pp04 using v_plnnr v_plnal
changing l_mdv01.
NOTE: when executing the above form\routine, if v_plnnr is initial
or v_plnal is initial, THEN l_mdv01 will automatically be
returned blank (ie initial)
else.
l_mdv01 = itab_xcel-mdv01.
endif.
build bdc script
perform bdc_build_script_record
fill in initial screen
using: 'X' 'SAPLCMFV' '1000',
' ' 'BDC_OKCODE' '=ENTE',
' ' 'MKAL-WERKS' itab_xcel-werks,
' ' 'MKAL-MATNR' v_matnr,
' ' 'MKAL_ADMIN-DISPO' space,
' ' 'MKAL-PLNNR' space,
' ' 'MKAL_ADMIN-STTAG' space,
' ' 'MKAL-PLNNG' space,
' ' 'MKAL-MDV01' space,
' ' 'MKAL-PLNNM' space,
click create button on initial screen and go to detail screen
'X' 'SAPLCMFV' '1000',
' ' 'BDC_OKCODE' '=CREA',
fill in the detail screen and go back to initial screen
'X' 'SAPLCMFV' '2000',
' ' 'BDC_OKCODE' '=CLOS',
' ' 'MKAL_EXPAND-MATNR' v_matnr,
' ' 'MKAL_EXPAND-VERID' itab_xcel-verid,
' ' 'MKAL_EXPAND-TEXT1' l_text1,
' ' 'MKAL_EXPAND-BSTMI' itab_xcel-bstmi,
' ' 'MKAL_EXPAND-BSTMA' itab_xcel-bstma,
' ' 'MKAL_EXPAND-ADATU' itab_xcel-adatu,
' ' 'MKAL_EXPAND-BDATU' itab_xcel-bdatu,
' ' 'MKAL_EXPAND-PLTYG' v_plnty,
' ' 'MKAL_EXPAND-PLNNG' v_plnnr,
' ' 'MKAL_EXPAND-ALNAG' v_plnal,
' ' 'MKAL_EXPAND-STLAL' itab_xcel-stlal,
' ' 'MKAL_EXPAND-STLAN' itab_xcel-stlan,
' ' 'MKAL_EXPAND-SERKZ' itab_xcel-serkz,
' ' 'MKAL_EXPAND-MDV01' l_mdv01,
' ' 'MKAL_EXPAND-ELPRO' itab_xcel-elpro,
' ' 'MKAL_EXPAND-ALORT' itab_xcel-alort,
save the production version from initial screen
'X' 'SAPLCMFV' '1000',
' ' 'BDC_OKCODE' '=SAVE'.
endform.
FORM BDC_SUBMIT_TRANSACTION *
Submit BDC Session *
form bdc_submit_transaction.
Load BDC script as a trqansction in BDC session
call function 'BDC_INSERT'
exporting
tcode = v_tcode
tables
dynprotab = itab_bdc_tab
exceptions
internal_error = 01
not_open = 02
queue_error = 03
tcode_invalid = 04.
endform.
FORM BDC_BUILD_SCRIPT_RECORD *
form bdc_build_script_record using dynbegin name value.
clear itab_bdc_tab.
if dynbegin = 'X'.
move: name to itab_bdc_tab-program,
value to itab_bdc_tab-dynpro,
'X' to itab_bdc_tab-dynbegin.
else.
move: name to itab_bdc_tab-fnam,
value to itab_bdc_tab-fval.
shift itab_bdc_tab-fval left deleting leading space.
endif.
append itab_bdc_tab.
endform.
FORM BDC_SESSION_CLOSE *
Close BDC Session *
form bdc_session_close.
close the session
call function 'BDC_CLOSE_GROUP'
exceptions
not_open = 1
queue_error = 2
others = 3.
skip 2.
if sy-subrc ne 0.
write: / 'Error Closing BDC Session ' , 'RETURN CODE: ', sy-subrc.
else.
write : / 'Session created:', v_ssnname,
50 '# of transactions:', v_trans_in_ssn.
endif.
endform.
*& Form read_routing_cache
*FORM read_routing_cache USING pi_matnr
pi_werks
pi_alnag
pi_verid
pi_mdv01.
DATA: BEGIN OF lt_plpo OCCURS 0,
vornr LIKE plpo-vornr,
objty LIKE crhd-objty,
objid LIKE crhd-objid,
arbpl LIKE crhd-arbpl,
END OF lt_plpo,
l_mapl_plnnr LIKE mapl-plnnr.
determine the routing group#
CLEAR lt_pp04_cache.
chk if its in the cache first, if not then get it from MAPL table
and put it in the cache
READ TABLE lt_pp04_cache WITH KEY matnr = pi_matnr
werks = pi_werks
alnag = pi_alnag.
IF sy-subrc = 0.
do nothing - lt_pp04_cache header line has rtg#
ELSE.
get the routing group # from MAPL
SELECT plnnr INTO l_mapl_plnnr
FROM mapl UP TO 1 ROWS
WHERE matnr = pi_matnr AND
werks = pi_werks AND
plnty = 'R' AND
plnal = pi_alnag AND
loekz = space.
ENDSELECT.
put it in the cache internal table
IF NOT l_mapl_plnnr IS INITIAL.
lt_pp04_cache-matnr = pi_matnr.
lt_pp04_cache-werks = pi_werks.
lt_pp04_cache-alnag = pi_alnag.
lt_pp04_cache-plnnr = l_mapl_plnnr.
APPEND lt_pp04_cache.
ENDIF.
ENDIF.
if the rtg# was determined AND
-- the work center was not determined yet AND
-- work center was really needed for this line in the input file
then
-- read the work center from last PP04 operation on the routing
-- update the cache accordingly
IF NOT lt_pp04_cache-plnnr IS INITIAL AND
lt_pp04_cache-arbpl IS INITIAL AND
( pi_verid IS INITIAL OR
pi_mdv01 IS INITIAL ).
read the last PP04 operation
CLEAR lt_plpo.
REFRESH lt_plpo.
SELECT vornr eobjty eobjid e~arbpl
INTO CORRESPONDING FIELDS OF TABLE lt_plpo
FROM plas AS b
INNER JOIN plpo AS c
ON bplnty = cplnty AND
bplnnr = cplnnr AND
bzaehl = czaehl
INNER JOIN crhd AS e
ON carbid = eobjid
WHERE b~plnty = v_plnty AND
b~plnnr = lt_pp04_cache-plnnr AND
b~plnal = lt_pp04_cache-alnag AND
c~loekz = space AND
c~steus = v_plpo_steus AND
e~objty = v_objty AND
e~werks = lt_pp04_cache-werks AND
e~verwe = v_verwe.
SORT lt_plpo BY vornr DESCENDING.
READ TABLE lt_plpo INDEX 1.
IF NOT lt_plpo-arbpl IS INITIAL.
lt_pp04_cache-arbpl = lt_plpo-arbpl.
read work center description
SELECT SINGLE ktext INTO lt_pp04_cache-ktext
FROM crtx WHERE objty = lt_plpo-objty AND
objid = lt_plpo-objid AND
spras = sy-langu.
the following read will get the index of the correct record to be
updated in the cache
READ TABLE lt_pp04_cache
WITH KEY matnr = pi_matnr
werks = pi_werks
alnag = pi_alnag.
MODIFY lt_pp04_cache
INDEX sy-tabix
TRANSPORTING arbpl ktext.
ENDIF.
ENDIF.
*ENDFORM. " read_last_pp04_operation_cache
*& Form read_routing
form read_routing.
data: begin of lt_mapl occurs 0,
plnnr like mapl-plnnr,
plnal like mapl-plnal,
end of lt_mapl,
l_arbpl like crhd-arbpl.
get all the rtg# and grp ctr# from MAPL
select plnnr plnal
into corresponding fields of table lt_mapl
from mapl
where matnr = v_matnr and
werks = itab_xcel-werks and
plnty = v_plnty and "Rate Routing
loekz = space. "with del flag = OFF
sort lt_mapl by plnal.
if not itab_xcel-verid is initial.
if the verid=0001 then use the 1st good rtg-grp# and grp-ctr#
if itab_xcel-verid = '0001'.
read table lt_mapl index 1.
v_plnnr = lt_mapl-plnnr.
v_plnal = lt_mapl-plnal.
else.
if the verid<>0001 then use the rtg-grp# and grp-ctr# of the routing
whose work center on the last PP04 operation matches the given verid
loop at lt_mapl.
clear l_arbpl.
get the work center from the last PP04 operation
perform read_wc_on_last_pp04 using lt_mapl-plnnr
lt_mapl-plnal
changing l_arbpl.
if itab_xcel-verid = l_arbpl.
v_plnnr = lt_mapl-plnnr.
v_plnal = lt_mapl-plnal.
exit.
endif.
endloop.
endif.
else.
do nothing
endif.
For version IDs that are other then '0000' or 'ZWIP' :--
if itab_xcel-verid NE '0000' and
itab_xcel-verid NE 'ZWIP'.
if routing group# or group counter was not determined, make the
valid-to date 99/99/9999 so that the BDC, on execution, errors out.
if v_plnnr is initial or
v_plnal is initial.
itab_xcel-bdatu = '99/99/9999'.
endif.
endif.
determine the routing group#
CLEAR lt_pp04_cache.
chk if its in the cache first, if not then get it from MAPL table
and put it in the cache
READ TABLE lt_pp04_cache WITH KEY matnr = pi_matnr
werks = pi_werks
alnag = pi_alnag.
IF sy-subrc = 0.
do nothing - lt_pp04_cache header line has rtg#
ELSE.
get the routing group # from MAPL
put it in the cache internal table
IF NOT l_mapl_plnnr IS INITIAL.
lt_pp04_cache-matnr = pi_matnr.
lt_pp04_cache-werks = pi_werks.
lt_pp04_cache-alnag = pi_alnag.
lt_pp04_cache-plnnr = l_mapl_plnnr.
APPEND lt_pp04_cache.
ENDIF.
ENDIF.
if the rtg# was determined AND
-- the work center was not determined yet AND
-- work center was really needed for this line in the input file
then
-- read the work center from last PP04 operation on the routing
-- update the cache accordingly
IF NOT lt_pp04_cache-plnnr IS INITIAL AND
lt_pp04_cache-arbpl IS INITIAL AND
( pi_verid IS INITIAL OR
pi_mdv01 IS INITIAL ).
read the last PP04 operation
CLEAR lt_plpo.
REFRESH lt_plpo.
SELECT vornr eobjty eobjid e~arbpl
INTO CORRESPONDING FIELDS OF TABLE lt_plpo
FROM plas AS b
INNER JOIN plpo AS c
ON bplnty = cplnty AND
bplnnr = cplnnr AND
bzaehl = czaehl
INNER JOIN crhd AS e
ON carbid = eobjid
WHERE b~plnty = v_plnty AND
b~plnnr = lt_pp04_cache-plnnr AND
b~plnal = lt_pp04_cache-alnag AND
c~loekz = space AND
c~steus = v_plpo_steus AND
e~objty = v_objty AND
e~werks = lt_pp04_cache-werks AND
e~verwe = v_verwe.
SORT lt_plpo BY vornr DESCENDING.
READ TABLE lt_plpo INDEX 1.
IF NOT lt_plpo-arbpl IS INITIAL.
lt_pp04_cache-arbpl = lt_plpo-arbpl.
read work center description
SELECT SINGLE ktext INTO lt_pp04_cache-ktext
FROM crtx WHERE objty = lt_plpo-objty AND
objid = lt_plpo-objid AND
spras = sy-langu.
the following read will get the index of the correct record to be
updated in the cache
READ TABLE lt_pp04_cache
WITH KEY matnr = pi_matnr
werks = pi_werks
alnag = pi_alnag.
MODIFY lt_pp04_cache
INDEX sy-tabix
TRANSPORTING arbpl ktext.
ENDIF.
ENDIF.
endform. " read_last_pp04_operation_cache
*& Form read_wc_on_last_pp04
form read_wc_on_last_pp04 using pi_plnnr
pi_plnal
changing pe_arbpl.
data: begin of lt_plpo occurs 0,
vornr like plpo-vornr,
objty like crhd-objty,
objid like crhd-objid,
arbpl like crhd-arbpl,
end of lt_plpo.
get all the PP04 operations for the given rtg# & grp-ctr#
select vornr eobjty eobjid e~arbpl
into corresponding fields of table lt_plpo
from plas as b
inner join plpo as c
on bplnty = cplnty and
bplnnr = cplnnr and
bzaehl = czaehl
inner join crhd as e
on carbid = eobjid
where b~plnty = v_plnty and "Rate Routing
b~plnnr = pi_plnnr and
b~plnal = pi_plnal and
c~loekz = space and "Oper Del Flag = OFF
c~steus = v_plpo_steus and "PP04
e~objty = v_objty. "WC Obj Type = 'A'
read the last operation
sort lt_plpo by vornr descending.
read table lt_plpo index 1.
pe_arbpl = lt_plpo-arbpl.
endform. " read_wc_on_last_pp04 -
BDC programming using Batch input Session.
Hello Experts.
I'm an ABAP beginner. I've benn practicing BDC programming using Batch input Session
at the moment.
This is the program that upload Local file which has plural records, and put the records into a Session.
These are the records.
413459,KIM EI HWAN121 ,19810607,MIADONG1234
423459,KIM EI HWAN122 ,19810607,MIADONG1235
433459,KIM EI HWAN123 ,19810607,MIADONG1236
443459,KIM EI HWAN124 ,19810607,MIADONG1237
453459,KIM EI HWAN125 ,19810607,MIADONG1238
463459,KIM EI HWAN126 ,19810607,MIADONG1239
I succeeded making Session.
However, for some reaseon, every record in the Session has got the same, value which is the first record.
Why is this happening? And How can I correct the code below?
REPORT ZBCUSER002_BATCH NO STANDARD PAGE HEADING
LINE-SIZE 255
MESSAGE-ID ZBATCH.
= Types definition ===================================================
TYPES: BEGIN OF TYP_LOCAL, "For Local file upload
RECORD(200) TYPE C,
END OF TYP_LOCAL.
= Internal table definition ==============================================
DATA: BEGIN OF BDC_TAB OCCURS 0. "BDCDATA itab
INCLUDE STRUCTURE BDCDATA.
DATA: END OF BDC_TAB.
DATA: BEGIN OF MESSAGE_BDC OCCURS 0. "Message itab
INCLUDE STRUCTURE BDCMSGCOLL.
DATA: END OF MESSAGE_BDC.
DATA: TBL_LOCAL TYPE STANDARD TABLE OF TYP_LOCAL, "Local file itab
F_TBL TYPE FILETABLE. "FILETABLE fot local
= Structure table definition =========================================
DATA: STR_F_TBL LIKE LINE OF F_TBL, "FILETABLE structure
STR_LOCAL TYPE TYP_LOCAL. "Local file structure
= Variable definition ================================================
DATA: LV_RC TYPE I, "Method parameter
ENUMBER TYPE ZT601-ENUMBER, "Employee number
NAME TYPE ZT601-NAME, "Employee name
BIRTH TYPE ZT601-BIRTH, "Birthday
HOMETOWN TYPE ZT601-HOMETOWN, "Hometown
SYSVAL TYPE SY-SUBRC. "System valuible
= Constants definition ===============================================
CONSTANTS: TBL_NAME(10) TYPE C VALUE 'ZT601'. "Table name ZT601
= Parameters definition ==============================================
PARAMETERS: F_NAME TYPE RLGRAP-FILENAME OBLIGATORY, "File path
EXECMODE(1) TYPE C. "Execute mode
INITIALIZATION
*----- Initialize all valuables, structures and internal tables
CLEAR: LV_RC,
STR_F_TBL,
STR_LOCAL,
ENUMBER,
NAME,
BIRTH,
HOMETOWN.
REFRESH: F_TBL,
TBL_LOCAL.
AT SELECTION-SCREEN
*----- When the button next to Parameter 'F_NAME',
*----- File dialog open.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR F_NAME.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
EXPORTING
WINDOW_TITLE = 'SELECT FILE'
DEFAULT_FILENAME = '*.TXT'
CHANGING
FILE_TABLE = F_TBL
RC = LV_RC
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
OTHERS = 3
*----- system valiable check.
*----- If done properly,
*----- Put the path into the File path parameter
IF SY-SUBRC = 0.
READ TABLE F_TBL INTO STR_F_TBL INDEX 1.
F_NAME = STR_F_TBL.
*----- If not done properly, show message
*----- An error occured while getting file path then end program
ELSE.
MESSAGE E000.
ENDIF.
*----- Execute code can only be A or N.
AT SELECTION-SCREEN ON EXECMODE.
IF EXECMODE <> 'A' AND EXECMODE <> 'N'.
MESSAGE E001.
ENDIF.
START-OF-SELECTION
START-OF-SELECTION.
*----- Upload Local file of file path parameter.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = F_NAME
FILETYPE = 'ASC'
TABLES
DATA_TAB = TBL_LOCAL
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
OTHERS = 6.
*----- System valiable check.
*----- If not done properly, show an error message
*----- An error occured while uploading local file then end program
IF SY-SUBRC <> 0.
MESSAGE E002.
ENDIF.
PERFORM BDC_OPEN.
*----- Loop Internal table
LOOP AT TBL_LOCAL INTO STR_LOCAL.
*----- Spilt the file record and put them into each valiable.
SPLIT STR_LOCAL AT ',' INTO ENUMBER
NAME
BIRTH
HOMETOWN.
*----- Data check Function module
CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
EXPORTING
DATE = BIRTH
EXCEPTIONS
PLAUSIBILITY_CHECK_FAILED = 1
OTHERS = 2.
*----- When error occurs while checking date, show an error message.
*----- (&1) is not date
IF SY-SUBRC <> 0.
MESSAGE E003 WITH BIRTH.
ENDIF.
*-- The first screen of SE11
*----- Screen number 0102 of program id SAPMSRD0
PERFORM BDC_DYNPRO USING 'SAPMSRD0' '0102'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RSRD1-TBMA_VAL'. "Field on Cursor
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=SHOW'. "Display button
PERFORM BDC_FIELD USING 'RSRD1-TBMA'
'X'.
PERFORM BDC_FIELD USING 'RSRD1-TBMA_VAL'
TBL_NAME. "ZT601
*-- Table definition screen
*----- Screen number 2000 of program id SAPLSD02
PERFORM BDC_DYNPRO USING 'SAPLSD02' '2000'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'DD02D-TABCLTEXT'. "Field on Cursor
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=TDED'. "Create entry
PERFORM BDC_FIELD USING 'BDC_SUBSCR'
'SAPLSD02'.
PERFORM BDC_FIELD USING 'BDC_SUBSCR'
'SAPLSED5'.
*-- Data input screen
*----- Screen number 0101 of program /1BCDWB/DBZT601
PERFORM BDC_DYNPRO USING '/1BCDWB/DBZT601' '0101'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'ZT601-CRUSER'. "Field on Cursor
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=SAVE'. "Save
PERFORM BDC_FIELD USING 'ZT601-MANDT'
SY-MANDT. "Client
PERFORM BDC_FIELD USING 'ZT601-ENUMBER'
ENUMBER. "Employee number
PERFORM BDC_FIELD USING 'ZT601-NAME'
NAME. "Employee name
PERFORM BDC_FIELD USING 'ZT601-BIRTH'
BIRTH. "Birthday
PERFORM BDC_FIELD USING 'ZT601-HOMETOWN'
HOMETOWN. "Hometown
PERFORM BDC_FIELD USING 'ZT601-CRDATE'
SY-DATUM. "System date
PERFORM BDC_FIELD USING 'ZT601-CRTIME'
SY-UZEIT. "System time
PERFORM BDC_FIELD USING 'ZT601-CRUSER'
SY-UNAME. "System user
*-- Data input screen (After input)
*----- Screen number 0101 of program /1BCDWB/DBZT601
PERFORM BDC_DYNPRO USING '/1BCDWB/DBZT601' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/EBACK'. "Back
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'ZT601-CRUSER'. "Field on Cursor
*-- Table definition screen]
*----- Screen number 2000 of program SAPLSD02
PERFORM BDC_DYNPRO USING 'SAPLSD02' '2000'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'DD02D-TABCLTEXT'. "Field on Cursor
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=WB_BACK'. "Back
*-- The first screen of SE11
*----- Screen number 0102 of program SAPMSRD0
PERFORM BDC_DYNPRO USING 'SAPMSRD0' '0102'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RSRD1-TBMA_VAL'. "Field on Cursor
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BACK'.
PERFORM BDC_FIELD USING 'RSRD1-TBMA'
'X'.
PERFORM BDC_FIELD USING 'RSRD1-TBMA_VAL'
TBL_NAME.
PERFORM BDC_INSERT.
ENDLOOP.
PERFORM BDC_CLOSE.
FORM BDC_DYNPRO *
Put Program-Id, Dynpro screen number, Start point
into DBCDATA
--> PROGRAM *
--> DYNPRO *
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDC_TAB.
BDC_TAB-PROGRAM = PROGRAM.
BDC_TAB-DYNPRO = DYNPRO.
BDC_TAB-DYNBEGIN = 'X'.
APPEND BDC_TAB.
ENDFORM.
FORM BDC_FIELD *
Put Field Name and Value into BDCDATA
--> FNAM *
--> FVAL *
FORM BDC_FIELD USING FNAM FVAL.
CLEAR BDC_TAB.
BDC_TAB-FNAM = FNAM.
BDC_TAB-FVAL = FVAL.
APPEND BDC_TAB.
ENDFORM.
FORM bdc_process *
FORM BDC_OPEN.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = 'Testsession'
KEEP = 'X'
USER = SY-UNAME.
IF SY-SUBRC <> 0.
MESSAGE E006 WITH SY-SUBRC.
ENDIF.
ENDFORM.
FORM bdc_insert *
FORM BDC_INSERT.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'SE11'
TABLES
DYNPROTAB = BDC_TAB
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 E007 WITH SY-SUBRC.
ENDIF.
CLEAR: BDC_TAB.
ENDFORM.
FORM bdc_close *
FORM BDC_CLOSE.
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE E008 WITH SY-SUBRC.
ENDIF.
ENDFORM.God I forgot to refresh Internal table after putting record into Session.
Now I'm done.
You guys be careful too. -
Hello!
I have a customer that usually have error status in BDC Sessions and they expect that original users clean up their sessions.
But they are looking for some task in background to help them, is it possible?
And he has another doubt:
"How does the system store the data used in the BDC session? If we have an error and need to correct the data or re-run the session, where will the tool pull the data for that session? We are trying to determine if failed sessions are leaving data on the unix filesystems, etc."
Thanks in advance,
Daniel Kaoro KobashigawaHi,
If you are using the BDC session methos then the error logs and other ino are stored in teh session in SM36
We can re-process the sessiions that are error ones seen in the Error records.
Search SDN more on this.
We have many threads on this issue.
If you are using the Call Transaction then we dont get the exact error but we can see the error records using BDCMSGCOLL.
Usually both are combined to handle the data in a accurate manner.
Regards
Lekha -
Mappimg and updation in bdc 'session ' and 'call transaction' methods
What will happen if error record comes while updating in session method and call transaction method.
Hi,
If any error comes in Session method U can find that error in SM35->Log
and updste again database for those enteries
In cll transaction Method U have to handel error manually . for this u have to use structure BDCMSGCOL and Table T100.
Regards
Gaurav -
Can anybody tell me the way so that i can find out which program has created the BDC session? I looked into APQI table but the PROGID field is blank. Is there any other way to find out the Program's name of BDC session?
I am able to see here. I do not understand why you are not able to see that.
Ok, try this, In the list of sessions displayed -> <b>double click the session</b> that an error (i.e. <b>Transaction Ended with errors).</b>
Then it will take you to another screen, here you choose the <b>Screens tab</b>.
You can find the program name here.
Regards
Kathirvel -
Problem in bdc session method for tcode FS00
Hi Experts,
problem in bdc session method, when i run this program no output is shown.
Even it is not calling the transaction.
code as follows.
*& Report Z_GL_MASTER
*& CATEGORY = BDC.
*& DESCRIPTION = UPLOADING G/L MASTER RECORDS.
*& TECHNICAL CONST = FRANCIS REDDY.
*& FUNTIONAL CONST = FICO.
REPORT Z_GL_MASTER.
*& Internal Table
DATA : BEGIN OF IT_UPLOAD OCCURS 0,
SAKNR LIKE GLACCOUNT_SCREEN_KEY-SAKNR, " ACCOUNT NUMBER.
BUKRS LIKE GLACCOUNT_SCREEN_KEY-BUKRS, " COMPANY CODE.
KTOKS LIKE GLACCOUNT_SCREEN_COA-KTOKS, " ACCOUNT GROUP.
XPLACCT LIKE GLACCOUNT_SCREEN_COA-XPLACCT, " P&L STATEMEMENT.
GVTYP LIKE GLACCOUNT_SCREEN_COA-GVTYP, " P&L STATEMENT TYPE.
XBILK LIKE GLACCOUNT_SCREEN_COA-XBILK, " BALANCE SHEET STATEMENT
SHORT LIKE GLACCOUNT_SCREEN_COA-TXT20_ML, " SHORT TEXT.
LONG LIKE GLACCOUNT_SCREEN_COA-TXT50_ML, " LONG TEXT.
WAERS LIKE GLACCOUNT_SCREEN_CCODE-WAERS, " ACCOUNT CURRENCY.
XSALH LIKE GLACCOUNT_SCREEN_CCODE-XSALH, " ONLY BALANCES IN LOCAL CURRENCY.
MITKZ LIKE GLACCOUNT_SCREEN_CCODE-MITKZ, " RECONCILATION ACCOUNT FOR ACCOUNT TYPEGLACCOUNT_SCREEN_CCODE-MITKZ
XOPVW LIKE GLACCOUNT_SCREEN_CCODE-XOPVW, " OPEN ITEM MANAGEMENT.
XKRES LIKE GLACCOUNT_SCREEN_CCODE-XKRES, " LINE ITEM DISPLAY.
ZUAWA LIKE GLACCOUNT_SCREEN_CCODE-ZUAWA, " SORT KEY.
FSTAG LIKE GLACCOUNT_SCREEN_CCODE-FSTAG, " FIELD STATUS GROUP.
XGKON LIKE GLACCOUNT_SCREEN_CCODE-XGKON, " RELAVENT CASH FLOW.
END OF IT_UPLOAD.
*& Internal Table FOR BDC DATA.
DATA : IT_BDCDATA TYPE BDCDATA OCCURS 0 WITH HEADER LINE.
*& DATA DECLARATIONS.
DATA : V_FILE LIKE RLGRAP-FILENAME.
*& SELECTION SCREEN.
PARAMETER : P_FILE LIKE V_FILE.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
PERFORM GET_FILENAME.
START-OF-SELECTION.
PERFORM UPLOAD_DATA.
PERFORM BDCDATA_OPEN.
PERFORM BDC_POPULATE.
PERFORM BDC_CLOSE.
*& Form GET_FILENAME
form GET_FILENAME .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE'
IMPORTING
FILE_NAME = P_FILE.
endform. " GET_FILENAME
*& Form UPLOAD_DATA
form UPLOAD_DATA .
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = P_FILE
FILETYPE = 'DAT'
TABLES
data_tab = IT_UPLOAD.
endform. " UPLOAD_DATA
*& Form BDCDATA_OPEN
FORM FOR BDC_OPEN_GROUP.
form BDCDATA_OPEN .
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = 'GLMASTER'
HOLDDATE = SY-DATUM
KEEP = 'X'
USER = SY-UNAME.
endform. " BDCDATA_OPEN
*& Form BDC_POPULATE
POPULATING BDC DATA .
form BDC_POPULATE .
loop at it_upload.
PERFORM BDC_SUB1 USING 'X' 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.
PERFORM BDC_SUB2 USING 'BDC_OKCODE' '=ACC_CRE'.
PERFORM BDC_SUB2 USING 'BDC_CURSOR' 'GLACCOUNT_SCREEN_KEY-SAKNR'.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_KEY-SAKNR' IT_UPLOAD-SAKNR.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_KEY-BUKRS' IT_UPLOAD-BUKRS.
PERFORM BDC_SUB1 USING 'X' 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.
PERFORM BDC_SUB2 USING 'BDC_OKCODE' '=2102_GROUP'.
PERFORM BDC_SUB2 USING 'BDC_CURSOR' 'GLACCOUNT_SCREEN_COA-KTOKS'.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_COA-KTOKS' IT_UPLOAD-KTOKS.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_COA-XPLACCT' IT_UPLOAD-XPLACCT.
PERFORM BDC_SUB1 USING 'X' 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.
PERFORM BDC_SUB2 USING 'BDC_OKCODE' '=2102_BS_PL'.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_COA-GVTYP' IT_UPLOAD-GVTYP.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_COA-XBILK' IT_UPLOAD-XBILK.
PERFORM BDC_SUB1 USING 'X' 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.
PERFORM BDC_SUB2 USING 'BDC_CURSOR' 'GLACCOUNT_SCREEN_COA-TXT20_ML'.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_COA-TXT20_ML' IT_UPLOAD-SHORT.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_COA-TXT50_ML' IT_UPLOAD-LONG.
PERFORM BDC_SUB1 USING 'X' 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.
PERFORM BDC_SUB2 USING 'BDC_OKCODE' '=TAB02'.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_CCODE-WAERS' IT_UPLOAD-WAERS.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_CCODE-XSALH' IT_UPLOAD-XSALH.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_CCODE-MITKZ' IT_UPLOAD-MITKZ.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_CCODE-XOPVW' IT_UPLOAD-XOPVW.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_CCODE-XKRES' IT_UPLOAD-XKRES.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_CCODE-ZUAWA' IT_UPLOAD-ZUAWA.
PERFORM BDC_SUB1 USING 'X' 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.
PERFORM BDC_SUB2 USING 'BDC_OKCODE' '=TAB03'.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_CCODE-FSTAG' IT_UPLOAD-FSTAG.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_CCODE-XGKON' IT_UPLOAD-XGKON.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'FS00'
TABLES
dynprotab = IT_BDCDATA.
endloop.
endform. " BDC_POPULATE
*& Form BDC_CLOSE
FORM FOR CLOSING BDC_GROUP
form BDC_CLOSE .
CALL FUNCTION 'BDC_CLOSE_GROUP'.
endform. " BDC_CLOSE
*& Form BDC_SUB1
FORM FOR BDCDATA.
form BDC_SUB1 USING A B C.
CLEAR IT_BDCDATA.
IT_BDCDATA-DYNBEGIN = A.
IT_BDCDATA-PROGRAM = B.
IT_BDCDATA-DYNPRO = C.
APPEND IT_BDCDATA.
endform. " BDC_SUB1
*& Form BDC_SUB2
text
form BDC_SUB2 USING A B.
CLEAR IT_BDCDATA.
IT_BDCDATA-FNAM = A.
IT_BDCDATA-FVAL = B.
APPEND IT_BDCDATA.
endform. " BDC_SUB2
Points will be rewarded.
Thanks in advance.
Francis.Hi,
Once the program is executed..It will a BDC session..
THen you have to use the transaction SM35..To process the BDC session..
Thanks,
Naren -
BDC Session Saves Data Only in Foreground
I have created a bdc program to create an SM35 session of CA02. The wierd thing is that the session will run in background with no errors, but the data is not updated. If I run the session in foreground the data is updated. Have I overlooked something simple?
To see what is going on, I commented out the save at the end to force it to error out. If I run the session in foreground the data is changed. If I run it in display errors only mode, the data is not changed. So it seems not to have anything to do with the save at the end. Perhaps it is now appropriate to post some of the code.
After the data file is uploaded into the itab and the bdc group has been created, for each routing group I do the following:
PERFORM dynpro USING:
* *** Initial Screen ***
'X' 'SAPLCPDI' '1010',
' ' 'RC271-PLNNR' gk_rec-groupnum,
' ' 'BDC_OKCODE' '/00',
* *** Header Overview ***
'X' 'SAPLCPDI' '1200',
' ' 'BDC_OKCODE' 'MTUE'. "open material allocation screen
Then for each material allocation the data file says to delete:
PERFORM dynpro USING:
* *** Material Allocation ***
'X' 'SAPLCZDI' '1010',
' ' 'RC27X-ENTRY_ACT' gv_entry, "gv_entry holds row number to delete
' ' 'BDC_OKCODE' 'ENT1', "position button
'X' 'SAPLCZDI' '1010',
' ' 'BDC_CURSOR' 'MAPL-MATNR(01)', "place cursor on the line to delete
' ' 'BDC_OKCODE' 'LOE', "delete line
'X' 'SAPLSPO1' '0100',
' ' 'BDC_OKCODE' 'YES'. "confirm dialog
then at the end of the session:
PERFORM dynpro USING:
'X' 'SAPLCZDI' '1010',
' ' 'BDC_OKCODE' 'BACK', "leave material allocation screen
'X' 'SAPLCPDI' '1200',
' ' 'BDC_OKCODE' 'BU'. "save
Then, I insert into the bdc session using tcode ca02. All this given the following subroutine:
FORM dynpro USING p_dynbegin TYPE any p_name TYPE any p_value TYPE any.
CLEAR gk_bdc_tab.
IF p_dynbegin = 'X'.
MOVE: p_name TO gk_bdc_tab-program,
p_value TO gk_bdc_tab-dynpro,
'X' TO gk_bdc_tab-dynbegin.
ELSE.
MOVE: p_name TO gk_bdc_tab-fnam,
p_value TO gk_bdc_tab-fval.
ENDIF.
APPEND gk_bdc_tab TO gt_bdc_tab.
ENDFORM.
It seems that the cursor isn't specifying the line to delete when run in background. -
About using rsbdcsub to run BDC session .
Hi all,
I use rsbdcsub to run a bdc session ,
But the job created by the program is always in "ready" status and never run(complete) .
How can I solve the problem?
Thanks
Pole
Message was edited by: gw gwHi Srinivas,
Thanks very much.You understood what I meant exectly.
Because the files provided by the several banks systems are not the same format,so we can not use the report RFEBKA00.And now we are developing the system connecting to the bank system directly,we can get the data from the bank and upload them to the sap system without creating a file.
So we use the FF67 BDC
The program like this:
"it_data" is the internal table containing the data from the bank system.
"l_mnam1" is the session name created by the program.
PERFORM fill_bdcdata USING:
'SAPMF40K' '0110' 'X',
'FEBMKA-FDIS_SEL' 'X' ' ',
'FEBMKA-VARI_START' 'TKL01' ' ',
'FEBMKA-DEBI_MID' 'D' ' ',
'FEBMKA-KRED_MID' 'K' ' ',
'FEBMKA-WVAR_ART' '2' ' ',
'FEBMKA-BUCH_VAL' 'X' ' ',
'BDC_OKCODE' '=ENTE' ' ',
'SAPMF40K' '0102' 'X',
'FEBMKA-BANKL' t012-bankl ' ',
'FEBMKA-BANKN' t012k-bankn ' ',
'FEBMKA-WAERS' 'CNY' ' ',
'FEBMKA-AZNUM' febko-aznum ' ',
'FEBMKA-AZDAT' l_azdat ' ',
'FEBMKA-SSALD' l_esbtr ' ',
'FEBMKA-ESALD' l_ssbtr ' ',
'FEBMKA-BUDTM' l_BUDTM ' ',
'FEBMKA-MNAM1' l_mnam1 ' ',
'BDC_OKCODE' '/00' ' ',
'SAPMF40K' '8000' 'X'.
SORT it_data BY valut.
LOOP AT it_data.
WRITE it_data-kwbtr TO l_kwbtr CURRENCY 'CNY'.
l_zuonr = it_data-zuonr.
PERFORM fill_bdcdata USING:
'FEBMKA-VGMAN(01)' it_data-vgman ' ',
'FEBEP-VALUT(01)' it_data-valut ' ',
'FEBMKA-KWBTR(01)' l_kwbtr ' ',
'FEBMKK-ZUONR_KF(01)' it_data-zuonr ' ',
'FEBMKK-SGTXT_KF(01)' l_zuonr ' ',
'BDC_OKCODE' '=ZINS' ' ',
'SAPMF40K' '8000' 'X'.
AT LAST.
PERFORM fill_bdcdata USING:
'BDC_OKCODE' '=SICH' ' '.
ENDAT.
ENDLOOP.
PERFORM fill_bdcdata USING:
'SAPMF40K' '0102' 'X',
'BDC_OKCODE' '=BUCH' ' ',
'SAPMF40K' '0102' 'X',
'BDC_OKCODE' '/EENDE' ' '.
l_mode = 'N'.
CALL TRANSACTION 'FF67' USING t_bdcdata MODE l_mode
UPDATE 'S'
MESSAGES INTO t_msg_tab.
Thanks again for your help.
Pole -
Hello Friends,
Can you guide me how to create BDC with SESSION method.?
Please mantion examples.
Thanks in advance.
Regards,
nimesh masterSee below example code :
Call three FM : BDC_OPEN_GROUP,BDC_INSERT and BDC_CLOSE_GROUP.
Once you execute the program and it creates the session at SM35 Transaction.
Report : ZMPPC011
Type : Data upload
Author : Chetan Shah
Date : 05/05/2005
Transport : DV3K919557
Transaction: ??
Description: This ABAP/4 Program creates new Production Versions
(C223). It accepts tab-delimited spreadsheet input and
creates BDC sessions.
Modification Log
Date Programmer Request # Description
06/10/2005 Chetan Shah DV3K919557 Initial coding
report zmppc011 no standard page heading line-size 120 line-count 55
message-id zz.
pool of form routines
include zmppn001.
Define BDC Table Structure
data: begin of itab_bdc_tab occurs 0.
include structure bdcdata.
data: end of itab_bdc_tab.
Input record layout of Leagcy File
data: begin of itab_xcel occurs 0,
matnr(18) type c,
werks(4) type c,
alnag(2) type c,
verid(4) type c,
text1(40) type c,
bstmi like mkal-bstmi,
bstma like mkal-bstma,
adatu(10) type c,
bdatu(10) type c,
stlal(2) type c,
stlan(1) type c,
serkz(1) type c,
mdv01(8) type c,
elpro(4) type c,
alort(4) type c,
end of itab_xcel.
data: begin of lt_pp04_cache occurs 0,
matnr like itab_xcel-matnr,
werks like itab_xcel-werks,
alnag like itab_xcel-alnag,
plnnr like mapl-plnnr,
arbpl like crhd-arbpl,
ktext like crtx-ktext,
end of lt_pp04_cache.
data: v_ssnnr(4) type n,
v_lines_in_xcel like sy-tabix,
v_ssnname like apqi-groupid,
v_trans_in_ssn type i,
wa_xcel LIKE itab_xcel,
l_tabix like sy-tabix,
v_matnr like rc27m-matnr,
v_plnnr like mapl-plnnr,
v_plnal like mapl-plnal,
v_tcode like sy-tcode value 'C223',
v_plnty like plas-plnty value 'R',
v_objty like crhd-objty value 'A',
v_plpo_steus like plpo-steus value 'PP04',
v_verwe like crhd-verwe value '0007'.
Parameters
selection-screen: skip 3.
selection-screen: begin of block 1 with frame.
parameters: p_name like rlgrap-filename
default 'C:\My Documents\InputFile.txt'
obligatory,
bdc session name prefix
p_bdcpfx(6) default 'ZPVCRT'
obligatory,
number for transction per BDC session
p_trnssn type i
default 2000 obligatory,
retain the BDC session after successfull execution
p_keep like apqi-qerase
default 'X',
user who will be executing BDC session
p_uname like apqi-userid
default sy-uname
obligatory.
selection-screen: end of block 1.
possible entry list (F4 dropdown) for input file name
at selection-screen on value-request for p_name.
*-SELECT FILE FROM USERS LOCAL PC
call function 'WS_FILENAME_GET'
exporting
DEF_FILENAME = ' '
def_path = 'C:\Temp\'
mask = ',.,..'
mode = 'O'
title = 'Select File '(007)
importing
filename = p_name
RC =
exceptions
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
others = 5.
if sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
begin the show
start-of-selection.
read data from input file
perform transfer_xcel_to_itab.
loop at itab_xcel.
hang on to xcel line num
l_tabix = sy-tabix.
each line in the xcel file marks begining of new prod.version defn
if num-of-trnas-in-session = 0, create new BDC session
if v_trans_in_ssn is initial.
perform bdc_session_open.
endif.
begin new bdc script for rtg create trans
fill in bdc-data for prod.version maintenance screens
perform bdc_build_script.
insert the bdc script as a BDC transaction
perform bdc_submit_transaction.
keep track of how many BDC transactions were inserted in the BDC
session
add 1 to v_trans_in_ssn.
if the user-specified num of trans in BDC session is reached OR
if end of input file is reached, close the BDC session
if v_trans_in_ssn = p_trnssn or
l_tabix = v_lines_in_xcel.
perform bdc_session_close.
clear v_trans_in_ssn.
endif.
endloop.
top-of-page.
call function 'Z_HEADER'
EXPORTING
FLEX_TEXT1 =
FLEX_TEXT2 =
FLEX_TEXT3 =
FORM TRANSFER_XCEL_TO_ITAB *
Transfer Xcel Spreadsheet to SAP Internal Table *
form transfer_xcel_to_itab.
Read the tab-delimited file into itab
call function 'WS_UPLOAD'
exporting
filename = p_name
filetype = 'DAT'
IMPORTING
filelength = flength
tables
data_tab = itab_xcel
exceptions
conversion_error = 1
file_open_error = 2
file_read_error = 3
invalid_table_width = 4
invalid_type = 5
no_batch = 6
unknown_error = 7
others = 8.
if sy-subrc = 0.
sort the data
sort itab_xcel by matnr werks.
clear v_lines_in_xcel.
if no data in the file - error out
describe table itab_xcel lines v_lines_in_xcel.
if v_lines_in_xcel is initial.
write: / 'No data in input file'.
stop.
endif.
else.
if file upload failed - error out
write: / 'Error reading input file'.
stop.
endif.
endform.
FORM BDC_SESSION_OPEN *
Open BDC Session *
form bdc_session_open.
create bdc session name = prefix-from-selectn-screen + nnnn
add 1 to v_ssnnr.
concatenate p_bdcpfx v_ssnnr into v_ssnname.
open new bdc session
call function 'BDC_OPEN_GROUP'
exporting
client = sy-mandt
group = v_ssnname
keep = p_keep
user = p_uname
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.
endform.
FORM BDC_BUILD_SCRIPT *
Build BDC *
form bdc_build_script.
data: l_arbpl like crhd-arbpl,
l_text1 like mkal-text1,
l_mdv01 like mkal-mdv01,
l_mapl like mapl.
clear bdc-data itab - begin of new bdc transaction
clear itab_bdc_tab.
refresh itab_bdc_tab.
read material cross reference tables to determine sap part#
clear : v_matnr, v_plnnr, v_plnal.
perform read_matnr_cross_ref using itab_xcel-matnr
itab_xcel-werks
changing v_matnr.
determine the version description to use
if itab_xcel-text1 is initial.
l_text1 = itab_xcel-verid.
else.
l_text1 = itab_xcel-text1.
endif.
determine the routing group# and group ctr# to use
perform read_routing .
determine the production line to use
if itab_xcel-mdv01 is initial.
if not provided in the file then:
prod line = work ctr on the last PP04 op of the rtg determined above
perform read_wc_on_last_pp04 using v_plnnr v_plnal
changing l_mdv01.
NOTE: when executing the above form\routine, if v_plnnr is initial
or v_plnal is initial, THEN l_mdv01 will automatically be
returned blank (ie initial)
else.
l_mdv01 = itab_xcel-mdv01.
endif.
build bdc script
perform bdc_build_script_record
fill in initial screen
using: 'X' 'SAPLCMFV' '1000',
' ' 'BDC_OKCODE' '=ENTE',
' ' 'MKAL-WERKS' itab_xcel-werks,
' ' 'MKAL-MATNR' v_matnr,
' ' 'MKAL_ADMIN-DISPO' space,
' ' 'MKAL-PLNNR' space,
' ' 'MKAL_ADMIN-STTAG' space,
' ' 'MKAL-PLNNG' space,
' ' 'MKAL-MDV01' space,
' ' 'MKAL-PLNNM' space,
click create button on initial screen and go to detail screen
'X' 'SAPLCMFV' '1000',
' ' 'BDC_OKCODE' '=CREA',
fill in the detail screen and go back to initial screen
'X' 'SAPLCMFV' '2000',
' ' 'BDC_OKCODE' '=CLOS',
' ' 'MKAL_EXPAND-MATNR' v_matnr,
' ' 'MKAL_EXPAND-VERID' itab_xcel-verid,
' ' 'MKAL_EXPAND-TEXT1' l_text1,
' ' 'MKAL_EXPAND-BSTMI' itab_xcel-bstmi,
' ' 'MKAL_EXPAND-BSTMA' itab_xcel-bstma,
' ' 'MKAL_EXPAND-ADATU' itab_xcel-adatu,
' ' 'MKAL_EXPAND-BDATU' itab_xcel-bdatu,
' ' 'MKAL_EXPAND-PLTYG' v_plnty,
' ' 'MKAL_EXPAND-PLNNG' v_plnnr,
' ' 'MKAL_EXPAND-ALNAG' v_plnal,
' ' 'MKAL_EXPAND-STLAL' itab_xcel-stlal,
' ' 'MKAL_EXPAND-STLAN' itab_xcel-stlan,
' ' 'MKAL_EXPAND-SERKZ' itab_xcel-serkz,
' ' 'MKAL_EXPAND-MDV01' l_mdv01,
' ' 'MKAL_EXPAND-ELPRO' itab_xcel-elpro,
' ' 'MKAL_EXPAND-ALORT' itab_xcel-alort,
save the production version from initial screen
'X' 'SAPLCMFV' '1000',
' ' 'BDC_OKCODE' '=SAVE'.
endform.
FORM BDC_SUBMIT_TRANSACTION *
Submit BDC Session *
form bdc_submit_transaction.
Load BDC script as a trqansction in BDC session
call function 'BDC_INSERT'
exporting
tcode = v_tcode
tables
dynprotab = itab_bdc_tab
exceptions
internal_error = 01
not_open = 02
queue_error = 03
tcode_invalid = 04.
endform.
FORM BDC_BUILD_SCRIPT_RECORD *
form bdc_build_script_record using dynbegin name value.
clear itab_bdc_tab.
if dynbegin = 'X'.
move: name to itab_bdc_tab-program,
value to itab_bdc_tab-dynpro,
'X' to itab_bdc_tab-dynbegin.
else.
move: name to itab_bdc_tab-fnam,
value to itab_bdc_tab-fval.
shift itab_bdc_tab-fval left deleting leading space.
endif.
append itab_bdc_tab.
endform.
FORM BDC_SESSION_CLOSE *
Close BDC Session *
form bdc_session_close.
close the session
call function 'BDC_CLOSE_GROUP'
exceptions
not_open = 1
queue_error = 2
others = 3.
skip 2.
if sy-subrc ne 0.
write: / 'Error Closing BDC Session ' , 'RETURN CODE: ', sy-subrc.
else.
write : / 'Session created:', v_ssnname,
50 '# of transactions:', v_trans_in_ssn.
endif.
endform.
*& Form read_routing_cache
*FORM read_routing_cache USING pi_matnr
pi_werks
pi_alnag
pi_verid
pi_mdv01.
DATA: BEGIN OF lt_plpo OCCURS 0,
vornr LIKE plpo-vornr,
objty LIKE crhd-objty,
objid LIKE crhd-objid,
arbpl LIKE crhd-arbpl,
END OF lt_plpo,
l_mapl_plnnr LIKE mapl-plnnr.
determine the routing group#
CLEAR lt_pp04_cache.
chk if its in the cache first, if not then get it from MAPL table
and put it in the cache
READ TABLE lt_pp04_cache WITH KEY matnr = pi_matnr
werks = pi_werks
alnag = pi_alnag.
IF sy-subrc = 0.
do nothing - lt_pp04_cache header line has rtg#
ELSE.
get the routing group # from MAPL
SELECT plnnr INTO l_mapl_plnnr
FROM mapl UP TO 1 ROWS
WHERE matnr = pi_matnr AND
werks = pi_werks AND
plnty = 'R' AND
plnal = pi_alnag AND
loekz = space.
ENDSELECT.
put it in the cache internal table
IF NOT l_mapl_plnnr IS INITIAL.
lt_pp04_cache-matnr = pi_matnr.
lt_pp04_cache-werks = pi_werks.
lt_pp04_cache-alnag = pi_alnag.
lt_pp04_cache-plnnr = l_mapl_plnnr.
APPEND lt_pp04_cache.
ENDIF.
ENDIF.
if the rtg# was determined AND
-- the work center was not determined yet AND
-- work center was really needed for this line in the input file
then
-- read the work center from last PP04 operation on the routing
-- update the cache accordingly
IF NOT lt_pp04_cache-plnnr IS INITIAL AND
lt_pp04_cache-arbpl IS INITIAL AND
( pi_verid IS INITIAL OR
pi_mdv01 IS INITIAL ).
read the last PP04 operation
CLEAR lt_plpo.
REFRESH lt_plpo.
SELECT vornr eobjty eobjid e~arbpl
INTO CORRESPONDING FIELDS OF TABLE lt_plpo
FROM plas AS b
INNER JOIN plpo AS c
ON bplnty = cplnty AND
bplnnr = cplnnr AND
bzaehl = czaehl
INNER JOIN crhd AS e
ON carbid = eobjid
WHERE b~plnty = v_plnty AND
b~plnnr = lt_pp04_cache-plnnr AND
b~plnal = lt_pp04_cache-alnag AND
c~loekz = space AND
c~steus = v_plpo_steus AND
e~objty = v_objty AND
e~werks = lt_pp04_cache-werks AND
e~verwe = v_verwe.
SORT lt_plpo BY vornr DESCENDING.
READ TABLE lt_plpo INDEX 1.
IF NOT lt_plpo-arbpl IS INITIAL.
lt_pp04_cache-arbpl = lt_plpo-arbpl.
read work center description
SELECT SINGLE ktext INTO lt_pp04_cache-ktext
FROM crtx WHERE objty = lt_plpo-objty AND
objid = lt_plpo-objid AND
spras = sy-langu.
the following read will get the index of the correct record to be
updated in the cache
READ TABLE lt_pp04_cache
WITH KEY matnr = pi_matnr
werks = pi_werks
alnag = pi_alnag.
MODIFY lt_pp04_cache
INDEX sy-tabix
TRANSPORTING arbpl ktext.
ENDIF.
ENDIF.
*ENDFORM. " read_last_pp04_operation_cache
*& Form read_routing
form read_routing.
data: begin of lt_mapl occurs 0,
plnnr like mapl-plnnr,
plnal like mapl-plnal,
end of lt_mapl,
l_arbpl like crhd-arbpl.
get all the rtg# and grp ctr# from MAPL
select plnnr plnal
into corresponding fields of table lt_mapl
from mapl
where matnr = v_matnr and
werks = itab_xcel-werks and
plnty = v_plnty and "Rate Routing
loekz = space. "with del flag = OFF
sort lt_mapl by plnal.
if not itab_xcel-verid is initial.
if the verid=0001 then use the 1st good rtg-grp# and grp-ctr#
if itab_xcel-verid = '0001'.
read table lt_mapl index 1.
v_plnnr = lt_mapl-plnnr.
v_plnal = lt_mapl-plnal.
else.
if the verid<>0001 then use the rtg-grp# and grp-ctr# of the routing
whose work center on the last PP04 operation matches the given verid
loop at lt_mapl.
clear l_arbpl.
get the work center from the last PP04 operation
perform read_wc_on_last_pp04 using lt_mapl-plnnr
lt_mapl-plnal
changing l_arbpl.
if itab_xcel-verid = l_arbpl.
v_plnnr = lt_mapl-plnnr.
v_plnal = lt_mapl-plnal.
exit.
endif.
endloop.
endif.
else.
do nothing
endif.
For version IDs that are other then '0000' or 'ZWIP' :--
if itab_xcel-verid NE '0000' and
itab_xcel-verid NE 'ZWIP'.
if routing group# or group counter was not determined, make the
valid-to date 99/99/9999 so that the BDC, on execution, errors out.
if v_plnnr is initial or
v_plnal is initial.
itab_xcel-bdatu = '99/99/9999'.
endif.
endif.
determine the routing group#
CLEAR lt_pp04_cache.
chk if its in the cache first, if not then get it from MAPL table
and put it in the cache
READ TABLE lt_pp04_cache WITH KEY matnr = pi_matnr
werks = pi_werks
alnag = pi_alnag.
IF sy-subrc = 0.
do nothing - lt_pp04_cache header line has rtg#
ELSE.
get the routing group # from MAPL
put it in the cache internal table
IF NOT l_mapl_plnnr IS INITIAL.
lt_pp04_cache-matnr = pi_matnr.
lt_pp04_cache-werks = pi_werks.
lt_pp04_cache-alnag = pi_alnag.
lt_pp04_cache-plnnr = l_mapl_plnnr.
APPEND lt_pp04_cache.
ENDIF.
ENDIF.
if the rtg# was determined AND
-- the work center was not determined yet AND
-- work center was really needed for this line in the input file
then
-- read the work center from last PP04 operation on the routing
-- update the cache accordingly
IF NOT lt_pp04_cache-plnnr IS INITIAL AND
lt_pp04_cache-arbpl IS INITIAL AND
( pi_verid IS INITIAL OR
pi_mdv01 IS INITIAL ).
read the last PP04 operation
CLEAR lt_plpo.
REFRESH lt_plpo.
SELECT vornr eobjty eobjid e~arbpl
INTO CORRESPONDING FIELDS OF TABLE lt_plpo
FROM plas AS b
INNER JOIN plpo AS c
ON bplnty = cplnty AND
bplnnr = cplnnr AND
bzaehl = czaehl
INNER JOIN crhd AS e
ON carbid = eobjid
WHERE b~plnty = v_plnty AND
b~plnnr = lt_pp04_cache-plnnr AND
b~plnal = lt_pp04_cache-alnag AND
c~loekz = space AND
c~steus = v_plpo_steus AND
e~objty = v_objty AND
e~werks = lt_pp04_cache-werks AND
e~verwe = v_verwe.
SORT lt_plpo BY vornr DESCENDING.
READ TABLE lt_plpo INDEX 1.
IF NOT lt_plpo-arbpl IS INITIAL.
lt_pp04_cache-arbpl = lt_plpo-arbpl.
read work center description
SELECT SINGLE ktext INTO lt_pp04_cache-ktext
FROM crtx WHERE objty = lt_plpo-objty AND
objid = lt_plpo-objid AND
spras = sy-langu.
the following read will get the index of the correct record to be
updated in the cache
READ TABLE lt_pp04_cache
WITH KEY matnr = pi_matnr
werks = pi_werks
alnag = pi_alnag.
MODIFY lt_pp04_cache
INDEX sy-tabix
TRANSPORTING arbpl ktext.
ENDIF.
ENDIF.
endform. " read_last_pp04_operation_cache
*& Form read_wc_on_last_pp04
form read_wc_on_last_pp04 using pi_plnnr
pi_plnal
changing pe_arbpl.
data: begin of lt_plpo occurs 0,
vornr like plpo-vornr,
objty like crhd-objty,
objid like crhd-objid,
arbpl like crhd-arbpl,
end of lt_plpo.
get all the PP04 operations for the given rtg# & grp-ctr#
select vornr eobjty eobjid e~arbpl
into corresponding fields of table lt_plpo
from plas as b
inner join plpo as c
on bplnty = cplnty and
bplnnr = cplnnr and
bzaehl = czaehl
inner join crhd as e
on carbid = eobjid
where b~plnty = v_plnty and "Rate Routing
b~plnnr = pi_plnnr and
b~plnal = pi_plnal and
c~loekz = space and "Oper Del Flag = OFF
c~steus = v_plpo_steus and "PP04
e~objty = v_objty. "WC Obj Type = 'A'
read the last operation
sort lt_plpo by vornr descending.
read table lt_plpo index 1.
pe_arbpl = lt_plpo-arbpl.
endform. " read_wc_on_last_pp04
Reward Points if it is useful
Thanks
Seshu
Maybe you are looking for
-
My SLD is configured in SOLMAN sys, How can I connect it with SAP PI system
Dear Friends My Basis has configured SLD in Solman, Now I cant use SXMB_IFR tcode in my PI that suggest me some error. saying "error in connection cant read secure connection config" or something like that. Plus SLDCHECK tcode is also not hap
-
How to build a dashboard in numbers
How would you build a dashboard in numbers?
-
Oracle BI Vs Sievel Analytics 7.8.x in Query Generation.
Hi All, In Siebel Analytics 7.8.x if you have 10 columns in the Criteria and if you are using only two columns in the Pivot table view, the query is generated to using only columns used in Pivot view. Where as in Oracle BI it uses all 10 columns in t
-
I can access Apple.com, Google Search and sites that I have to log into; but I cannot enter a Bookmark, enter a typed in URL or click on a link in Google Search and go to it. I have 4 browsers and they all have the same issue. Help!! OSX 10.9.3 Safa
-
I have this requirement for loding budget data for new products . The issue is that at the moment the business does not know what would be the Product id associated with such new products . They want to put them under a dummyid and later when the pro