Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

BDC session method

Former Member
0 Kudos

Hai, I am Ramesh

can you please clarify my doubt that is how to process the session log(error) in BDC session method

Thanks

1 ACCEPTED SOLUTION

SantoshKallem
Active Contributor
0 Kudos

SM35.

you can not process the error lo. but u can process the session.

to view the error log select the session and press analysis, you can see the information about how many records updated and not updated,

if if it is not updated, it show on which screen it got error, etc...

regards.

santhosh reddy

rectify the error records in flat file and run the bdc program for rectified flat file

just u can analyze the errors in sm35

reward all useful

Edited by: Santhosh Reddy on Feb 1, 2008 8:01 AM

4 REPLIES 4

SantoshKallem
Active Contributor
0 Kudos

SM35.

you can not process the error lo. but u can process the session.

to view the error log select the session and press analysis, you can see the information about how many records updated and not updated,

if if it is not updated, it show on which screen it got error, etc...

regards.

santhosh reddy

rectify the error records in flat file and run the bdc program for rectified flat file

just u can analyze the errors in sm35

reward all useful

Edited by: Santhosh Reddy on Feb 1, 2008 8:01 AM

0 Kudos

Hai Santhos

can't we process the error log then how to update our records to database

Thanks

Former Member
0 Kudos

Hi

Hope it will help you.

Reward if help.

SESSION METHOD

- It is one of the BDC techniques for uploading legacy data into SAP

- The data is transferring from the internal table to database table

through sessions.

- Data along with its action is stored in session.

- When the program has finished generating the session, you can run

the session to execute the transaction.

- Unless session is processed, the data is not transferred to

database tables.

- The following Function Modules are used in the session method.

1. BDC_OPEN_GROUP (Used to create the session)

Import Parameters :

USER - User Name

CLIENT - Client

GROUP - Name of the session

HOLD - The date when you want to process the session

KEEP - ‘X’ – retain session even after processing it

' ' - Delete the session after processing.

2. BDC_INSERT (Data is transferred to session)

Import Parameters :

TCODE - Transaction code

DYNPROTAB – BDCDATA table

3. BDC_CLOSE_GROUP (Used to close a session)

- Processing Steps

1. Generate the batch input session using function module

BDC_OPEN_GROUP.

2. The proceed as follows for each transaction that the session

contains:

a. In the BDCDATA structure, enter the value for all screens

and fields that must be processed in the transaction.

b. Use BDC_INSERT to transfer the transaction and the BDCDATA

structure to the session.

3. Close the batch input session with BDC_CLOSE_GROUP.

4. Start to process the generated session in T.Code SM35.

WT IS CALL TRANSACTION METHOD? WT IS SYNTAX/PROCEDURE?

CALL TRANSACTION :

1. It is compatible for small amount of data only.

2. It process the data Synchronously. i.e., The data is updated

at the time of execution.

3. It updates data both Synchronously and Asynchronously. When

we use Synchronous mode, it always verify all the data updated

successfully in the database.

When we use Asynchronous mode, the system can not wait till

all the data updated in the database.

4. It can handle only one application at a time.

5. It does not have Log file, we need to design logfile explicitly

using BDCMSGCOLL stucture.

Syntax :

CALL TRANSACTION <T.Code> USING <BDCTAB> MODE <A/N/E> UPDATE <S/A>

MESSAGES INTO <BDCMSGCOLL Int.Table>

Parameter 1 : Transaction Code

Parameter 2 : It is name of BDCDATA table.

Parameter 3 : Specifying Mode in which you execute transaction.

A - All screen mode. All the screen of transaction

are displayed.

N - No screen mode. No screen is displayed when you

execute the transaction.

E - Error screen. Only those screens are displayed

where you have error record.

Parameter 4 : Specifying Update type by which data base table is

updated.

S - It is for Synchronous update in which if you

change data for one table then all the relacted

tables gets updated. And then sy-subrc is returned

i.e., sy-subrc is returned for once and all.

A - It is for Asynchronous update, when you change

data of one table, the sy-subrc is returned. And

then updation of other affected tables takes place

If system fails to update other tables still

sy-subrc returned is 0.

Parameter 5 : When you update database table, operation is either

successful or unsuccessful or operation is successful

with some warning. These messages are stored in

internal table which you specify along with MESSAGE

statement. This internal table should be declared like

BDCMSGCOLL structure.

Steps for CALL TRANSACTION Method :

1. Interanal table for the data (structure similler to local file)

2. BDCTAB like BDCDATA.

3. Use UPLOAD/WS_UPLOAD/GUI_UPLOAD or DATASETS for upload data from

local file to internal table (i.e. ITAB).

4. LOOP at Itab.

Populate BDCTAB table.

CALL TRANSACTION <T.Code> USING <BDCTAB> MODE <A/N/E>

UPDATE <S/A> MESSAGES INTO <BDCMSGCOLL Int.Table>

Refresh BDCTAB.

ENDLOOP.

Former Member
0 Kudos

Hi

Hope it will help you.

Reward if help.

How to deal with table control / step loop in BDC

Steploop and table contol is inevitable in certain transactions. When we run BDC for such transactions, we will face the situation: how many visible lines of steploop/tablecontrol are on the screen? Although we can always find certain method to deal with it, such as function code 'NP', 'POPO', considering some extreme situation: there is only one line visible one the screen, our BDC program should display an error message. (See transaction 'ME21', we you resize your screen to let only one row visible, you can not enter mutiple lines on this screen even you use 'NP')

Now with the help of Poonam on sapfans.com developement forum, I find a method with which we can determine the number of visible lines on Transaction Screen from our Calling BDC program. Maybe it is useless to you, but I think it will give your some idea.

Demo ABAP code has two purposes:

1. how to determine number of visible lines and how to calculte page number;

(the 'calpage' routine has been modify to meet general purpose usage)

2. using field symbol in BDC program, please pay special attention to the difference in Static ASSIGN and Dynamic ASSIGN.

Now I begin to describe the step to implement my method:

(I use transaction 'ME21', screen 121 for sample,

the method using is Call Transation Using..)

Step1: go to screen painter to display the screen 121, then we can count the fixed line on this screen, there is 7 lines above the steploop and 2 lines below the steploop, so there are total 9 fixed lines on this screen. This means except these 9 lines, all the other line is for step loop. Then have a look at steploop itselp, one entry of it will occupy two lines.

(Be careful, for table control, the head and the bottom scroll bar will possess another two fixed lines, and there is a maximum number for table line)

Now we have : FixedLine = 9

LoopLine = 2(for table control, LoopLine is always equal to 1)

Step2: go to transaction itself(ME21) to see how it roll page, in ME21, the first line of new page is always occupied by the last line of last page, so it begin with index '02', but in some other case, fisrt line is empty and ready for input.

Now we have: FirstLine = 0

or FirstLine = 1 ( in our case, FirstLine is 1 because the first line of new page is fulfilled)

Step3: write a subroutine calcalculating number of pages

(here, the name of actual parameter is the same as formal parameter)

global data: FixedLine type i, " number of fixed line on a certain screen

LoopLine type i, " the number of lines occupied by one steploop item

FirstLine type i, " possbile value 0 or 1, 0 stand for the first line of new " scrolling screen is empty, otherwise is 1

Dataline type i, " number of items you will use in BDC, using DESCRIBE to get

pageno type i, " you need to scroll screen how many times.

line type i, " number of lines appears on the screen.

index(2) type N, " the screen index for certain item

begin type i, " from parameter of loop

end type i. " to parameter of loop

*in code sample, the DataTable-linindex stands for the table index number of this line

form calpage using FixedLine type i (see step 1)

LoopLine type i (see step 1)

FirstLine type i (see step 2)

DataLine type i ( this is the item number you will enter in transaction)

changing pageno type i (return the number of page, depends on run-time visible line in table control/ Step Loop)

changing line type i.(visible lines one the screen)

data: midd type i,

vline type i, "visible lines

if DataLine eq 0.

Message eXXX.

endif.

vline = ( sy-srows - FixedLine ) div LoopLine.

*for table control, you should compare vline with maximum line of

*table control, then take the small one that is min(vline, maximum)

*here only illustrate step loop

if FirstLine eq 0.

pageno = DataLine div vline.

if pageno eq 0.

pageno = pageno + 1.

endif.

elseif FirstLine eq 1.

pageno = ( DataLine - 1 ) div ( vline - 1 ) + 1.

midd = ( DataLine - 1 ) mod ( vline - 1).

if midd = 0 and DataLine gt 1.

pageno = pageno - 1.

endif.

endif.

line = vline.

endform.

Step4 write a subroutine to calculate the line index for each item.

form calindex using Line type i (visible lines on the screen)

FirstLine type i(see step 2)

LineIndex type i(item index)

changing Index type n. (index on the screen)

if FirstLine = 0.

index = LineIndex mod Line.

if index = '00'.

index = Line.

endif.

elseif FirstLine = 1.

index = LineIndex mod ( Line - 1 ).

if ( index between 1 and 0 ) and LineIndex gt 1.

index = index + Line - 1.

endif.

if Line = 2.

index = index + Line - 1.

endif.

endif.

endform.

Step5 write a subroutine to calculate the loop range.

form calrange using Line type i ( visible lines on the screen)

DataLine type i

FirstLine type i

loopindex like sy-index

changing begin type i

end type i.

If FirstLine = 0.

if loopindex = 1.

begin = 1.

if DataLine <= Line.

end = DataLine.

else.

end = Line.

endif.

elseif loopindex gt 1.

begin = Line * ( loopindex - 1 ) + 1.

end = Line * loopindex.

if end gt DataLine.

end = DataLine.

endif.

endif.

elseif FirstLine = 1.

if loopindex = 1.

begin = 1.

if DataLine <= Line.

end = DataLine.

else.

end = Line.

endif.

elseif loop index gt 1.

begin = ( Line - 1 ) * ( loopindex - 1 ) + 2.

end = ( Line - 1 ) * ( loopindex - 1 ) + Line.

if end gt DataLine.

end = DataLine.

endif.

endif.

endif.

endform.

Step6 using field sysbol in your BDC, for example: in ME21, but you should calculate each item will correponding to which index in steploop/Table Control

form creat_bdc.

field-symbols: <material>, <quan>, <indicator>.

data: name1(14) value 'EKPO-EMATN(XX)',

name2(14) value 'EKPO-MENGE(XX)',

name3(15) value 'RM06E-SELKZ(XX)'.

assign: name1 to <material>,

name2 to <quan>,

name3 to <indicator>.

.

do pageno times.

if sy-index gt 1

*insert scroll page ok_code"

endif.

.

.

perform calrange using Line DataLine FirstLine sy-index

changing begin end.

.

.

loop at DataTable from begin to end.

perform calindex using Line FirstLine DataTable-LineIndex changing Index.

name1+11(2) = Index.

name2+11(2) = Index.

name3+12(2) = Index.

.

.

perform bdcfield using <material> DataTable-matnr.

perform bdcfield using <quan> DataTable-menge.

perform bdcfield using <indicator> DataTable-indicator.

.

.

.

endloop.

enddo.