Application Development and Automation 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: 
Read only

Sessions method Vs Call Transaction

Former Member
0 Likes
1,136

Hi friends,

Please clarify me whether Sessions / Call transaction methods supports multiple transactions, If possible, how ???

Thanks

Suren

1 ACCEPTED SOLUTION
Read only

former_member297642
Participant
0 Likes
974

Hi,

The Session Method allows multiple transactions to be processed but CALL TRANSACTION method allows only a single transaction to be processed by SAP.

Example :

We need to create each structure, Internal table. work area for every transaction.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

CLIENT = SY-MANDT

GROUP = 'ERROR'

KEEP = 'X'

USER = SY-UNAME.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = 'Tcode1'

TABLES

DYNPROTAB = I_BDCDATA1 .

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = 'Tcode2'

TABLES

DYNPROTAB = I_BDCDATA2 .

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = 'Tcode3'

TABLES

DYNPROTAB = I_BDCDATA3 .

CALL FUNCTION 'BDC_CLOSE_GROUP' .

This is the way to work with multiple transcations in Session method.

Reward if helpful.

Regards,

Ranjith.

5 REPLIES 5
Read only

Former Member
0 Likes
974

create 2 recordings, call one first then when complete, you can call another. Is that simple.

Open BDC session.

BDC session 1.

{

All BDc screens

}

call transaction using 'VA01'.

BDC session 2.

{

All BDC screens.

}

call transaction using 'VL01N'.

close bdc session.

Hope this helps.

Andrew

Read only

former_member297642
Participant
0 Likes
975

Hi,

The Session Method allows multiple transactions to be processed but CALL TRANSACTION method allows only a single transaction to be processed by SAP.

Example :

We need to create each structure, Internal table. work area for every transaction.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

CLIENT = SY-MANDT

GROUP = 'ERROR'

KEEP = 'X'

USER = SY-UNAME.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = 'Tcode1'

TABLES

DYNPROTAB = I_BDCDATA1 .

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = 'Tcode2'

TABLES

DYNPROTAB = I_BDCDATA2 .

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = 'Tcode3'

TABLES

DYNPROTAB = I_BDCDATA3 .

CALL FUNCTION 'BDC_CLOSE_GROUP' .

This is the way to work with multiple transcations in Session method.

Reward if helpful.

Regards,

Ranjith.

Read only

Former Member
0 Likes
974

Hello surendranath,

Call transcation can handle only one Transcation and

Session method can handle 2 transcation codes a a time.

Here i will provide you a sample code for MK01 using Session method. What u have to do for multiple transcation is you can to create

&----


*

*& PURPOSE : This BDC report is used to upload all the vendor master

*& data in to SAP using SESSION METHOD with handling the errors

*&----


*

report Y035_SESSION_METHOD

no standard page heading line-size 255.

&----


*& Structure declaration

&----


*Structure Declaration for source internal table

TYPES : BEGIN OF TY_UPLOAD,

LIFNR TYPE RF02K-LIFNR,

EKORG TYPE RF02K-EKORG,

KTOKK TYPE RF02K-KTOKK,

NAME1 TYPE LFA1-NAME1,

SORTL TYPE LFA1-SORTL,

LAND1 TYPE LFA1-LAND1,

SPRAS TYPE LFA1-SPRAS,

WAERS TYPE LFM1-WAERS,

END OF TY_UPLOAD.

&----


*& Internal Table declaration

&----


*Internal Table Declaration for source table

DATA : T_UPLOAD TYPE STANDARD TABLE OF TY_UPLOAD INITIAL SIZE 0,

*Internal Table Declaration for bdcdata

T_BDCDATA TYPE STANDARD TABLE OF BDCDATA INITIAL SIZE 0,

*Internal table declaration for BDCMSGCOLL (To handle the errors)

T_BDCMSG TYPE STANDARD TABLE OF BDCMSGCOLL,

*Internal table declaration for reprocess the errors

T_ERRORS TYPE STANDARD TABLE OF TY_UPLOAD INITIAL SIZE 0,

&----


*& Workarea declaration

&----


*Work area delaration for source table

W_UPLOAD TYPE TY_UPLOAD,

*Work area delaration for bdcdata

W_BDCDATA TYPE BDCDATA,

*Work area delaration for BDCMSGCOLL

W_BDCMSG TYPE BDCMSGCOLL.

&----


*& Selection screen declaration

&----


*Selection Screen declaration

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.

PARAMETERS : P_FLNAME TYPE FILENAME.

SELECTION-SCREEN END OF BLOCK B1.

&----


*& Start of selection declaration

&----


*Start of selection declaration

START-OF-SELECTION.

*Upload the data

PERFORM SUB_UPLOAD_DATA.

*Populate the BDC data

PERFORM SUB_POPULATE_BDC.

*Process the error records

PERFORM SUB_ERROR_RECORD.

*include bdcrecx1.

&----


*& Form SUB_UPLOAD_DATA

&----


This subroutine is used to upload the data

-


FORM SUB_UPLOAD_DATA .

DATA : L_FLNAME TYPE STRING.

L_FLNAME = P_FLNAME.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = L_FLNAME

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = T_UPLOAD.

ENDFORM. " SUB_UPLOAD_DATA

&----


*& Form SUB_POPULATE_BDC

&----


This subroutine is used to populate the BDC data

-


FORM SUB_POPULATE_BDC .

DATA : L_MSG TYPE STRING.

*To oper a sesion in SE35

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

CLIENT = SY-MANDT

GROUP = 'MAMA_SESSION'

USER = SY-UNAME

KEEP = 'X'

HOLDDATE = '20080129'

PROG = SY-CPROG.

LOOP AT T_UPLOAD INTO W_UPLOAD.

REFRESH T_BDCDATA.

perform bdc_dynpro using 'SAPMF02K' '0107'.

perform bdc_field using 'BDC_CURSOR' 'RF02K-KTOKK'.

perform bdc_field using 'BDC_OKCODE' '/00'.

perform bdc_field using 'RF02K-LIFNR' W_UPLOAD-LIFNR.

perform bdc_field using 'RF02K-EKORG' W_UPLOAD-EKORG.

perform bdc_field using 'RF02K-KTOKK' W_UPLOAD-KTOKK.

perform bdc_dynpro using 'SAPMF02K' '0110'.

perform bdc_field using 'BDC_CURSOR' 'LFA1-SPRAS'.

perform bdc_field using 'BDC_OKCODE' '/00'.

perform bdc_field using 'LFA1-NAME1' W_UPLOAD-NAME1.

perform bdc_field using 'LFA1-SORTL' W_UPLOAD-SORTL.

perform bdc_field using 'LFA1-LAND1' W_UPLOAD-LAND1.

perform bdc_field using 'LFA1-SPRAS' W_UPLOAD-SPRAS.

perform bdc_dynpro using 'SAPMF02K' '0120'.

perform bdc_field using 'BDC_CURSOR' 'LFA1-KUNNR'.

perform bdc_field using 'BDC_OKCODE' '/00'.

perform bdc_dynpro using 'SAPMF02K' '0310'.

perform bdc_field using 'BDC_CURSOR' 'LFM1-WAERS'.

perform bdc_field using 'BDC_OKCODE' '/00'.

perform bdc_field using 'LFM1-WAERS' W_UPLOAD-WAERS.

perform bdc_dynpro using 'SAPMF02K' '0320'.

perform bdc_field using 'BDC_CURSOR' 'RF02K-LIFNR'.

perform bdc_field using 'BDC_OKCODE' '=ENTR'.

perform bdc_dynpro using 'SAPLSPO1' '0300'.

perform bdc_field using 'BDC_OKCODE' '=YES'.

**Transfer data to the session...Here u have to call this function *module BDC_INSERT again to use another T code say MM01 *and provide its name in parameter TCODE = MM01, here u have to create another structure, internal tables for MM01*

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = 'MK01'

TABLES

dynprotab = T_BDCDATA.

ENDLOOP.

*To close the session

CALL FUNCTION 'BDC_CLOSE_GROUP'.

ENDFORM. " SUB_POPULATE_BDC

-


Start new screen *

-


FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR W_BDCDATA.

W_BDCDATA-PROGRAM = PROGRAM.

W_BDCDATA-DYNPRO = DYNPRO.

W_BDCDATA-DYNBEGIN = 'X'.

APPEND W_BDCDATA TO T_BDCDATA.

ENDFORM.

-


Insert field *

-


FORM BDC_FIELD USING FNAM FVAL.

CLEAR W_BDCDATA.

W_BDCDATA-FNAM = FNAM.

W_BDCDATA-FVAL = FVAL.

APPEND W_BDCDATA TO T_BDCDATA.

ENDFORM.

&----


*& Form SUB_ERROR_RECORD

&----


This subroutine is used to process the error records

in to a file T_ERRORS

-


FORM SUB_ERROR_RECORD .

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = 'C:\MAMA_ERRORS.TXT'

WRITE_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = T_ERRORS.

ENDFORM. " SUB_ERROR_RECORD

*********************This is the way we work with muliple transcation codes **********

We need to create Structure, Internal table, Work area for every corresponding Transaction Code.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

CLIENT = SY-MANDT

GROUP = 'ERROR'

KEEP = 'X'

USER = SY-UNAME.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = 'MK01'

TABLES

DYNPROTAB = I_BDCDATA1 .

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = 'MM01'

TABLES

DYNPROTAB = I_BDCDATA2 .

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = 'Tcode3'

TABLES

DYNPROTAB = I_BDCDATA3 .

CALL FUNCTION 'BDC_CLOSE_GROUP' .

Hope the Explonation and information I had provided will resolve your issue.

Reward points if information is Helpful.

Have a great day!

Regards,

Krishna Chaitanya

Edited by: Krishna Chaitanya on Apr 7, 2008 5:21 AM

Read only

Former Member
0 Likes
974

Hi,

It is possible by session method.

Check the below sample program that how to handle multple transactions.

REPORT zra_gl_cr NO STANDARD PAGE HEADING LINE-SIZE 255.

TYPE-POOLS: truxs.

DATA: it_raw TYPE truxs_t_text_data.

DATA:messtab1 LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.

DATA:messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.

DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF i_mess OCCURS 0,

l_mstring(480),

msgnr(5),

msgv1(15),

END OF i_mess.

DATA:i_mess1 LIKE i_mess OCCURS 0 WITH HEADER LINE.

DATA: l_mstring(480),l_mstring1(480).

DATA: BEGIN OF it_itab OCCURS 0,

saknr(10), "G/L a/c number.

bukrs(4), "Company Code.

ktoks(4), "G/L a/c group.

xplacct(1), "P&L statement account.

xbilk(1), "Balance sheet account.

txt20_ml(20), "G/L a/c short text.

txt50_ml(50), "G/L a/c long text.

waers(5), "Account currency.

MWSKZ(2),

mitkz(1), "Reconciliation a/c for a/c type.

xopvw(1), "Open item management

xkres(1), "Line item display.

zuawa(3), "Sort Key.

fstag(4), "Field status group.

xintb(1), "Post automatically only.

hbkid(5), "House bank.

hktid(5), "Account id.

vzskz(2), "Interest indicator

END OF it_itab.

DATA: hdate LIKE sy-datum.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 5(15) text-103. " FOR FIELD P_FILE1.

SELECTION-SCREEN POSITION 25.

PARAMETERS : p_file1 LIKE rlgrap-filename.

SELECTION-SCREEN END OF LINE.

INITIALIZATION.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file1.

  • Perform file_selection will help to select the location of the file

PERFORM file_selection.

START-OF-SELECTION.

  • Perform data_upload will help to upload the data from the flat file

  • to the internal table.

PERFORM data_upload.

  • PERFORM open_group.

  • Peform bdc_upload will help to upload the data from the internal

  • table into its respective fields.

  • PERFORM bdc_fspo.

PERFORM bdc_upload.

PERFORM exp_log.

  • PERFORM close_group.

  • Perform display_log will prepare a log for the data that has been

  • uploaded

  • PERFORM display_log.

END-OF-SELECTION.

FORM file_selection .

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

def_filename = ' '

def_path = 'C:\'

mask = ',.txt,.xls.'

mode = 'O'

title = 'Open a excel file'

IMPORTING

filename = p_file1

EXCEPTIONS

inv_winsys = 1

no_batch = 2

selection_cancel = 3

selection_error = 4

OTHERS = 5.

ENDFORM. " file_selection

FORM data_upload .

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

  • I_FIELD_SEPERATOR =

i_line_header = 'X'

i_tab_raw_data = it_raw

i_filename = p_file1

TABLES

i_tab_converted_data = it_itab

EXCEPTIONS

conversion_failed = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDFORM. " data_upload

FORM bdc_upload .

LOOP AT it_itab.

perform bdc_dynpro using 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.

perform bdc_field using 'BDC_OKCODE'

'=ACC_CRE'.

perform bdc_field using 'BDC_CURSOR'

'GLACCOUNT_SCREEN_KEY-SAKNR'.

perform bdc_field using 'GLACCOUNT_SCREEN_KEY-SAKNR'

it_itab-SAKNR.

perform bdc_field using 'GLACCOUNT_SCREEN_KEY-BUKRS'

it_itab-BUKRS.

perform bdc_dynpro using 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.

perform bdc_field using 'BDC_OKCODE'

'=2102_GROUP'.

perform bdc_field using 'BDC_CURSOR'

'GLACCOUNT_SCREEN_COA-KTOKS'.

perform bdc_field using 'GLACCOUNT_SCREEN_COA-KTOKS'

it_itab-KTOKS.

perform bdc_field using 'GLACCOUNT_SCREEN_COA-XPLACCT'

it_itab-XPLACCT.

perform bdc_dynpro using 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.

perform bdc_field using 'BDC_OKCODE'

'=2102_BS_PL'.

perform bdc_field using 'BDC_CURSOR'

'GLACCOUNT_SCREEN_COA-XBILK'.

perform bdc_field using 'GLACCOUNT_SCREEN_COA-KTOKS'

it_itab-KTOKS.

perform bdc_field using 'GLACCOUNT_SCREEN_COA-XPLACCT'

it_itab-XPLACCT.

perform bdc_field using 'GLACCOUNT_SCREEN_COA-XBILK'

it_itab-XBILK.

perform bdc_dynpro using 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.

perform bdc_field using 'BDC_OKCODE'

'=ENTER'.

perform bdc_field using 'GLACCOUNT_SCREEN_COA-KTOKS'

it_itab-KTOKS.

perform bdc_field using 'GLACCOUNT_SCREEN_COA-XBILK'

it_itab-XBILK.

perform bdc_field using 'GLACCOUNT_SCREEN_COA-TXT20_ML'

it_itab-TXT20_ML.

perform bdc_field using 'GLACCOUNT_SCREEN_COA-TXT50_ML'

it_itab-TXT50_ML.

perform bdc_field using 'BDC_CURSOR'

'GLACCOUNT_SCREEN_COA-BILKT'.

perform bdc_field using 'GLACCOUNT_SCREEN_COA-BILKT'

it_itab-saknr.

PERFORM bdc_dynpro USING 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=TAB02'.

PERFORM bdc_field USING 'BDC_CURSOR'

'GLACCOUNT_SCREEN_COA-KTOKS'.

PERFORM bdc_field USING 'GLACCOUNT_SCREEN_COA-KTOKS'

it_itab-ktoks.

PERFORM bdc_field USING 'GLACCOUNT_SCREEN_COA-TXT20_ML'

it_itab-txt20_ml.

PERFORM bdc_field USING 'GLACCOUNT_SCREEN_COA-TXT50_ML'

it_itab-txt50_ml.

perform bdc_field using 'BDC_CURSOR'

'GLACCOUNT_SCREEN_COA-BILKT'.

perform bdc_field using 'GLACCOUNT_SCREEN_COA-BILKT'

it_itab-saknr.

****

perform bdc_dynpro using 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.

perform bdc_field using 'BDC_OKCODE'

'=TAB02'.

perform bdc_field using 'BDC_CURSOR'

'GLACCOUNT_SCREEN_COA-KTOKS'.

perform bdc_field using 'GLACCOUNT_SCREEN_COA-KTOKS'

it_itab-KTOKS.

perform bdc_field using 'BDC_CURSOR'

'GLACCOUNT_SCREEN_COA-KTOKS'.

perform bdc_field using 'GLACCOUNT_SCREEN_COA-KTOKS'

it_itab-KTOKS.

perform bdc_field using 'GLACCOUNT_SCREEN_COA-XBILK'

it_itab-XBILK.

perform bdc_field using 'GLACCOUNT_SCREEN_COA-TXT20_ML'

it_itab-TXT20_ML.

perform bdc_field using 'GLACCOUNT_SCREEN_COA-TXT50_ML'

it_itab-TXT50_ML.

perform bdc_field using 'GLACCOUNT_SCREEN_COA-BILKT'

it_itab-saknr.

perform bdc_dynpro using 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.

perform bdc_field using 'BDC_OKCODE'

'=ENTER'.

perform bdc_field using 'GLACCOUNT_SCREEN_CCODE-WAERS'

it_itab-waers.

perform bdc_field using 'GLACCOUNT_SCREEN_CCODE-MWSKZ'

it_itab-MWSKZ.

perform bdc_field using 'GLACCOUNT_SCREEN_CCODE-MITKZ'

it_itab-mitkz.

perform bdc_field using 'BDC_CURSOR'

'GLACCOUNT_SCREEN_CCODE-XOPVW'.

perform bdc_field using 'GLACCOUNT_SCREEN_CCODE-XOPVW'

it_itab-XOPVW.

perform bdc_field using 'GLACCOUNT_SCREEN_CCODE-XKRES'

it_itab-XKRES.

perform bdc_field using 'GLACCOUNT_SCREEN_CCODE-ZUAWA'

it_itab-ZUAWA.

*******************

PERFORM bdc_field USING 'GLACCOUNT_SCREEN_COA-XPLACCT'

it_itab-xplacct.

PERFORM bdc_field USING 'GLACCOUNT_SCREEN_COA-XBILK'

it_itab-xbilk.

  • IF it_itab-xbilk = 'X'.

*

  • PERFORM bdc_dynpro USING 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.

  • PERFORM bdc_field USING 'BDC_OKCODE'

  • '=TAB03'.

  • PERFORM bdc_field USING 'BDC_CURSOR'

  • 'GLACCOUNT_SCREEN_CCODE-WAERS'.

  • PERFORM bdc_field USING 'GLACCOUNT_SCREEN_CCODE-WAERS'

  • it_itab-waers.

*

  • PERFORM bdc_field USING 'GLACCOUNT_SCREEN_CCODE-XOPVW'

  • it_itab-xopvw.

  • PERFORM bdc_field USING 'GLACCOUNT_SCREEN_CCODE-MITKZ'

  • it_itab-mitkz.

  • ENDIF.

  • PERFORM bdc_field USING 'GLACCOUNT_SCREEN_CCODE-XKRES'

  • it_itab-xkres.

  • PERFORM bdc_field USING 'GLACCOUNT_SCREEN_CCODE-ZUAWA'

  • it_itab-zuawa.

*

  • PERFORM bdc_dynpro USING 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.

*

  • PERFORM bdc_field USING 'BDC_OKCODE'

  • '=SAVE'.

  • PERFORM bdc_field USING 'BDC_CURSOR'

  • 'GLACCOUNT_SCREEN_CCODE-FSTAG'.

  • PERFORM bdc_field USING 'GLACCOUNT_SCREEN_CCODE-FSTAG'

  • it_itab-fstag.

  • PERFORM bdc_field USING 'GLACCOUNT_SCREEN_CCODE-XINTB'

  • it_itab-xintb.

  • PERFORM bdc_field USING 'GLACCOUNT_SCREEN_CCODE-HBKID'

  • it_itab-hbkid.

  • PERFORM bdc_field USING 'GLACCOUNT_SCREEN_CCODE-HKTID'

  • it_itab-hktid.

  • PERFORM bdc_field USING 'GLACCOUNT_SCREEN_CCODE-VZSKZ'

  • it_itab-vzskz.

perform bdc_dynpro using 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.

perform bdc_field using 'BDC_OKCODE'

'=TAB03'.

perform bdc_field using 'BDC_CURSOR'

'GLACCOUNT_SCREEN_CCODE-WAERS'.

perform bdc_field using 'GLACCOUNT_SCREEN_CCODE-WAERS'

it_itab-WAERS.

perform bdc_field using 'GLACCOUNT_SCREEN_CCODE-MWSKZ'

it_itab-MWSKZ.

perform bdc_field using 'GLACCOUNT_SCREEN_CCODE-MITKZ'

it_itab-MITKZ.

perform bdc_field using 'GLACCOUNT_SCREEN_CCODE-ZUAWA'

it_itab-ZUAWA.

perform bdc_dynpro using 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.

perform bdc_field using 'BDC_OKCODE'

'=ENTER'.

perform bdc_field using 'BDC_CURSOR'

'GLACCOUNT_SCREEN_CCODE-FSTAG'.

perform bdc_field using 'GLACCOUNT_SCREEN_CCODE-FSTAG'

it_itab-FSTAG.

perform bdc_dynpro using 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.

perform bdc_field using 'BDC_OKCODE'

'=SAVE'.

perform bdc_field using 'BDC_CURSOR'

'GLACCOUNT_SCREEN_CCODE-FSTAG'.

perform bdc_field using 'GLACCOUNT_SCREEN_CCODE-FSTAG'

it_itab-FSTAG.

  • PERFORM bdc_transaction USING 'FS00'.

CALL TRANSACTION 'FS00' USING bdcdata MODE 'A'

UPDATE 'S'

MESSAGES INTO messtab1.

PERFORM mess1.

REFRESH bdcdata[].

ENDLOOP.

ENDFORM. " bdc_upload

FORM bdc_fspo .

LOOP AT it_itab.

PERFORM bdc_dynpro USING 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ACC_CRE'.

PERFORM bdc_field USING 'BDC_CURSOR'

'GLACCOUNT_SCREEN_KEY-SAKNR'.

PERFORM bdc_field USING 'GLACCOUNT_SCREEN_KEY-SAKNR'

it_itab-saknr.

PERFORM bdc_field USING 'GLACCOUNT_SCREEN_KEY-KTOPL'

'1000'.

PERFORM bdc_dynpro USING 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=2102_GROUP'.

PERFORM bdc_field USING 'BDC_CURSOR'

'GLACCOUNT_SCREEN_COA-KTOKS'.

PERFORM bdc_field USING 'GLACCOUNT_SCREEN_COA-KTOKS'

it_itab-ktoks.

PERFORM bdc_field USING 'GLACCOUNT_SCREEN_COA-XPLACCT'

it_itab-xplacct.

PERFORM bdc_field USING 'GLACCOUNT_SCREEN_COA-XBILK'

it_itab-xbilk.

PERFORM bdc_dynpro USING 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=SAVE'.

PERFORM bdc_field USING 'GLACCOUNT_SCREEN_COA-KTOKS'

it_itab-ktoks.

PERFORM bdc_field USING 'GLACCOUNT_SCREEN_COA-XPLACCT'

it_itab-xplacct.

PERFORM bdc_field USING 'BDC_CURSOR'

'GLACCOUNT_SCREEN_COA-TXT50_ML'.

PERFORM bdc_field USING 'GLACCOUNT_SCREEN_COA-TXT20_ML'

it_itab-txt20_ml.

PERFORM bdc_field USING 'GLACCOUNT_SCREEN_COA-TXT50_ML'

it_itab-txt50_ml.

*perform bdc_transaction using 'FSP0'.

CALL TRANSACTION 'FSP0' USING bdcdata MODE 'A'

UPDATE 'S'

MESSAGES INTO messtab.

PERFORM mess.

REFRESH bdcdata[].

ENDLOOP.

ENDFORM. " bdc_fspo

FORM mess . "fsp0

LOOP AT messtab.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

id = messtab-msgid

lang = messtab-msgspra

no = messtab-msgnr

v1 = messtab-msgv1

v2 = messtab-msgv2

v3 = messtab-msgv3

v4 = messtab-msgv4

IMPORTING

msg = l_mstring

EXCEPTIONS

not_found = 1

OTHERS = 2.

CONDENSE l_mstring.

i_mess1-l_mstring = l_mstring(250).

i_mess1-msgnr = messtab1-msgnr.

i_mess1-msgv1 = messtab1-msgv1.

APPEND i_mess1.

ENDLOOP.

ENDFORM. " mess

FORM mess1 . "fs00

LOOP AT messtab1.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

id = messtab1-msgid

lang = messtab1-msgspra

no = messtab1-msgnr

v1 = messtab1-msgv1

v2 = messtab1-msgv2

v3 = messtab1-msgv3

v4 = messtab1-msgv4

IMPORTING

msg = l_mstring1

EXCEPTIONS

not_found = 1

OTHERS = 2.

CONDENSE l_mstring1.

i_mess-l_mstring = l_mstring1(250).

i_mess-msgnr = messtab1-msgnr.

i_mess-msgv1 = messtab1-msgv1.

APPEND i_mess.

ENDLOOP.

ENDFORM. " mess1

FORM exp_log .

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = 'c:\temp\error_fsp0.txt'

filetype = 'DAT'

TABLES

data_tab = i_mess1.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = 'c:\temp\error_fs00.txt'

filetype = 'DAT'

TABLES

data_tab = i_mess.

ENDFORM. " exp_log

FORM bdc_dynpro USING program dynpro.

CLEAR bdcdata.

bdcdata-program = program.

bdcdata-dynpro = dynpro.

bdcdata-dynbegin = 'X'.

APPEND bdcdata.

ENDFORM. "BDC_DYNPRO

FORM bdc_field USING fnam fval.

CLEAR bdcdata.

bdcdata-fnam = fnam.

bdcdata-fval = fval.

APPEND bdcdata.

ENDFORM. "BDC_Field

Regards

Kiran

Read only

Former Member
0 Likes
974

Hi,

you can handle multipe transactions using session method.

.Use the function module in the following sequence.

BDC_OPEN_GROUP.

BDC_INSERT. " for the first TCODE

BDC_INSERT. " for the second TCODE

BDC_CLOSE_GROUP.

This will solve your problem

just spend some time on the documentation given below ,

so that you will get a clear picture on the functionality of session and call transaction method.

I

Batch Data Communication (BDC)

BDC is not a typical integration tool, it is used for uploading data into R/3.

The input comes in the form of a flat file. The ABAP program reads this file and formats the input data screen by screen into an internal table (BDCDATA). The transaction is then started using this internal table as the input and executed in the background.

BATCH INPUT SESSION METHOD:

1) This is a sequence of transactions, which is generated when user run a particular program.

2) Session Method can transfer LARGE amount of data.

3) But Session Method data processing is slower.

4) In this Session Method error log is created

5) In this Session Method until the session is processed data is not updated .

6) In this Session Method sy-subrc is not returned.

7) This is Synchronous processing

CALL TRANSACTION METHOD:

1) This is Asynchronous processing

2) Call Transaction can transfer SMALL amount of data.

3) In Call Transaction data processing is faster.

4) In this Call Transaction Method errors need to be handled explicitly :

In this Call Transaction method, the transactions are triggered at the time of processing itself. So the ABAP program must do the error handling. It can also be used for real-time interfaces and custom error handling & logging features.

5) In this Call Transaction Method data is updated automatically.

6) In this Call transaction is sy-subrc is returned.

Some more information

Batch Input Session method is asynchronous as told by others here. But the advantage of this is that you have all the error messages and the data for each transaction held persistantly. You don't have to code anything for processing them or writing the logs.

But at the same time, the same feature can be disadvantageous if you need to react to an error or if there are too many errors to manually correct in a session. Since the session are created in the program and its execution is done seperately, you loose the trackability of such transactions.

With a call transaction, what was a disadvantage above will become an advantage. Call transaction immediately gives you messages back and you can react to it in your program. But the disadvantage is that, if you have several hundreds of transactions to run, running them from within the program can be resource crunching affair. It will hamper the system performance and you cannot really distribute the load. Of course, you have some mechanisms with which you can overcome this, but you will have to code for it. Also, storing the messages and storing the errored transaction data etc will have to be handled by you in the program. Whereas, in batch input session, your program's job is to just create the session, after that everything is standard SAP system's responsibility.

Ideally, you should do a call transaction if the resources are not a problem and if it fails, put the errored transaction into a session.

You can decide based on the data volume that your BDC is processing. If data volume is high go for session else call transaction will do.The call transaction updates will be instantaneous where as session needs to be processed explictly after creation.

you can do it both manually and by using program RSBDCSUB

Check these link:

http://www.sap-img.com/abap/difference-between-batch-input-and-call-transaction-in-bdc.htm

http://www.sap-img.com/abap/question-about-bdc-program.htm

http://www.itcserver.com/blog/2006/06/30/batch-input-vs-call-transaction/

http://www.planetsap.com/bdc_main_page.htm

Hope u can understand this.

Reward if useful.

Edited by: K.R.Reddy on Apr 7, 2008 12:05 PM