‎2007 Jan 30 1:14 PM
Hi everyone,
I'm new to bdc programing.i'm getting confuse with call transaction and session methods.
can anyone explain me the difference between call transaction and session method with a simple example.
‎2007 Jan 30 1:18 PM
‎2007 Jan 30 1:23 PM
Hi,
Call transaction :
the transaction will be called immediatly when u run the report and the recording will be done once u execute the program...
Session method:
Session method will create a session ... U can schedule the session at any time so that it runs at the specified time..
Let us suppose that u need to enter some 1000 materials using MM01.. when u run this during normal working hours, it consumes time and server may lose its pace..
to avoid this , u can create a session for this data upload and schedule the session when users are less...say friday night..
hope this will be useful
Cheers
Rajiv
‎2007 Jan 30 1:23 PM
There are so many differences are there b/w call transaction and Session method.
In call Transaction u can update the data in synchronous as well as asynchronous.
in session method error log will be there, in call transaction u have to write code manualyy.
In session method u can run multiple transactions at a time, in call transaction only one transaction at a time
‎2007 Jan 30 1:23 PM
hi the simplest difference between these two is call transaction makes the program run right when u execute the program
whereas when we use session programming there is a session created in SM35 where it can be set for execution at a particular time or even can be set for background(foregorund) processing
an example would be like this
START-OF-SELECTION.
IF CAL_TRA = 'X'.
PERFORM CALL_TRANSACTION.
ENDIF.
IF SESSION = 'X'.
FLAG = 'X'.
PERFORM SESSION_METHOD.
ENDIF.
&----
*& Form CALL_TRANSACTION
&----
text
----
FORM CALL_TRANSACTION.
V_FILE = P_FILE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = V_FILE
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = IT_SALES
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT IT_SALES.
PERFORM POPULATE_BDC.
CALL TRANSACTION 'VA01' USING IT_BDCDATA
MODE MODE
UPDATE UPDATE
MESSAGES INTO IT_MSGS.
IF NOT IT_MSGS[] IS INITIAL.
LOOP AT IT_MSGS.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = IT_MSGS-MSGID
LANG = 'EN'
NO = IT_MSGS-MSGNR
V1 = IT_MSGS-MSGV1
V2 = IT_MSGS-MSGV2
V3 = IT_MSGS-MSGV3
V4 = IT_MSGS-MSGV4
IMPORTING
MSG = V_MSG
EXCEPTIONS
NOT_FOUND = 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.
WRITE:/ V_MSG.
ENDLOOP.
ENDIF.
ENDLOOP.
ENDFORM. "CALL_TRANSACTION
&----
*& Form SESSION_METHOD
&----
text
----
FORM SESSION_METHOD.
V_FILE = P_FILE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = V_FILE
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = IT_SALES
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = SES_NAM
HOLDDATE = LOC_DATE
KEEP = KEP_TRAS
USER = USER.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT IT_SALES.
PERFORM POPULATE_BDC.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'VA01'
TABLES
DYNPROTAB = IT_BDCDATA
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN = 2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 6
OTHERS = 7.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDLOOP.
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "SESSION_METHOD
----
Start new screen *
----
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR IT_BDCDATA.
IT_BDCDATA-PROGRAM = PROGRAM.
IT_BDCDATA-DYNPRO = DYNPRO.
IT_BDCDATA-DYNBEGIN = 'X'.
APPEND IT_BDCDATA.
ENDFORM. "BDC_DYNPRO
----
Insert field *
----
FORM BDC_FIELD USING FNAM FVAL.
CLEAR IT_BDCDATA.
IT_BDCDATA-FNAM = FNAM.
IT_BDCDATA-FVAL = FVAL.
APPEND IT_BDCDATA.
ENDFORM. "BDC_FIELD
*&----
&----
*& Form populate_bdc
&----
text
----
FORM POPULATE_BDC.
CLEAR IT_MSGS.
REFRESH IT_MSGS.
CLEAR IT_BDCDATA.
REFRESH IT_BDCDATA.
PERFORM BDC_DYNPRO USING 'SAPMV45A' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'VBAK-AUART'
IT_SALES-AUART.
PERFORM BDC_FIELD USING 'VBAK-VKORG'
IT_SALES-VKORG.
PERFORM BDC_FIELD USING 'VBAK-VTWEG'
IT_SALES-VTWEG.
PERFORM BDC_DYNPRO USING 'SAPMV45A' '4001'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'VBKD-BSTKD'
IT_SALES-BSTKD.
PERFORM BDC_FIELD USING 'KUAGV-KUNNR'
IT_SALES-KUNNR_KUNAG.
PERFORM BDC_FIELD USING 'KUWEV-KUNNR'
IT_SALES-KUNNR_KUNWE.
PERFORM BDC_DYNPRO USING 'SAPMSSY0' '0120'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=CHOO'.
PERFORM BDC_DYNPRO USING 'SAPMV45A' '4001'.
PERFORM BDC_FIELD USING 'RV45A-KETDAT'
IT_SALES-KETDAT.
PERFORM BDC_FIELD USING 'RV45A-KPRGBZ'
IT_SALES-KPRGBZ.
PERFORM BDC_FIELD USING 'VBKD-PRSDT'
IT_SALES-PRSDT.
PERFORM BDC_DYNPRO USING 'SAPMV45A' '4001'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'VBKD-BSTKD'
IT_SALES-BSTKD_1.
PERFORM BDC_FIELD USING 'KUAGV-KUNNR'
IT_SALES-KUNNR_KUNAG1.
PERFORM BDC_FIELD USING 'KUWEV-KUNNR'
IT_SALES-KUNNR_KUNWE1.
PERFORM BDC_FIELD USING 'RV45A-KETDAT'
IT_SALES-KETDAT_1.
PERFORM BDC_FIELD USING 'RV45A-KPRGBZ'
IT_SALES-KPRGBZ_1.
PERFORM BDC_FIELD USING 'VBKD-PRSDT'
IT_SALES-PRSDT_1.
PERFORM BDC_FIELD USING 'VBKD-ZTERM'
IT_SALES-ZTERM_1.
PERFORM BDC_FIELD USING 'VBKD-INCO1'
IT_SALES-INCO1.
PERFORM BDC_FIELD USING 'VBKD-INCO2'
IT_SALES-INCO2.
PERFORM BDC_FIELD USING 'RV45A-MABNR(01)'
IT_SALES-MABNR.
PERFORM BDC_FIELD USING 'RV45A-KWMENG(01)'
IT_SALES-KWMENG.
PERFORM BDC_DYNPRO USING 'SAPMV45A' '4001'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=PKO1'.
PERFORM BDC_FIELD USING 'VBKD-BSTKD'
IT_SALES-BSTKD_2.
PERFORM BDC_FIELD USING 'KUAGV-KUNNR'
IT_SALES-KUNNR_KUNAG2.
PERFORM BDC_FIELD USING 'KUWEV-KUNNR'
IT_SALES-KUNNR_KUNWE2.
PERFORM BDC_FIELD USING 'RV45A-KETDAT'
IT_SALES-KETDAT_2.
PERFORM BDC_FIELD USING 'RV45A-KPRGBZ'
IT_SALES-KPRGBZ_2.
PERFORM BDC_FIELD USING 'VBKD-PRSDT'
IT_SALES-PRSDT_2.
PERFORM BDC_FIELD USING 'VBKD-ZTERM'
IT_SALES-ZTERM_2.
PERFORM BDC_FIELD USING 'VBKD-INCO1'
IT_SALES-INCO1_1.
PERFORM BDC_FIELD USING 'VBKD-INCO2'
IT_SALES-INCO2_2.
PERFORM BDC_DYNPRO USING 'SAPMV45A' '5003'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'KOMV-KSCHL(08)'
IT_SALES-KSCHL.
PERFORM BDC_DYNPRO USING 'SAPMV45A' '5003'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'KOMV-KBETR(02)'
IT_SALES-KBETR.
PERFORM BDC_DYNPRO USING 'SAPMV45A' '5003'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=SICH'.
ENDFORM. "populate_bdc
‎2007 Jan 30 1:24 PM
In Call Transaction, the transactions are triggered at the time of processing itself and so the ABAP program must do the error handling. It can also be used for real-time interfaces and custom error handling & logging features. Whereas in
Batch Input Sessions, the ABAP program creates a session with all the transactional data, and this session can be viewed, scheduled and processed (using Transaction SM35) at a later time. The latter technique has a built-in error processing mechanism too.
difference between batch input and call transaction in BDC
Session method.
1) synchronous processing.
2) can tranfer large amount of data.
3) processing is slower.
4) error log is created
5) data is not updated until session is processed.
Call transaction.
1) asynchronous processing
2) can transfer small amount of data
3) processing is faster.
4) errors need to be handled explicitly
5) data is updated automatically
‎2007 Jan 30 1:27 PM
Hi krishna ...
in a nutshell........
in call transaction first recording is done and only a syntax CALL TRANSACTION <TCODE> USING BDCTAB MODE A/E/N UPDATE S/A MESSAGES INTO BDCMSGCOLL is used...here all the error messages are explicitly seen thru bdcmsgcoll.....once executed the program..process starts...
in session method after recording three fms are called
bdc_open_group
bdc_insert
bdc_close_group
built in error log in sm35 where u can view the errors
hence only when the session is processed in tcode sm35..process starts..in th sense all the data is kept in session and processed
however i suggest u to go thru the general diffrences between these two...
following are few links which can help u to get a better idea
http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
http://www.sap-img.com/abap/learning-bdc-programming.htm
hope this helps,
all the best,
sampath
*mark helpful answers and close the thread if query solved
Message was edited by:
sampath pilla
‎2007 Jan 30 1:34 PM
Hi Krishna,
BDC SESSION
CALL TRANSACTION
CALL DIALOG
What is BDC or batch input
The Batch Input is a SAP technic that allows automating the input in transactions. It lies on a BDC (Batch Data Commands) scenario.
BDC functions:
E BDC_OPEN_GROUP : Opens a session group
E BDC_CLOSE_GROUP : Closes a session
E BDC_INSERT : Insert a BDC scenario in the session
E The ABAP statement "CALL TRANSACTION" is also called to run directly a transaction from its BDC table.
It runs the program RSBDCSUB in order to launch automatically the session. The session management is done through the transaction code SM35.
The object itself is maintanable through the transaction SE24.
BDC methods:
Method
Description
Parameters
OPEN_SESSION
Opens a session
SUBRC (Return Code ? 0 OK)
SESSIONNAME (Session to be created)
CLOSE_SESSION
Closes a session
None
RESET_BDCDATA
Resets the BDC Internal Table...
None. Normally, for internal purposec
BDC_DYNPRO
Handles a new screen
PROGNAME (Name of the program)
DYNPRONR (Screen Number)
BDC_FIELD
Puts a value on the screen
FIELDNAME (Name of the field)
FIELDVALUE (Value to be passed)
CONSTRUCTOR
Constructor - Initializes NO_DATA
NODATA (No data character). The constructor is called automatically when the object is created.
RUN_SESSION
Launches a session with RSBDCBTC
None
CALL_TRANSACTION
Calls a transaction with the current BDC Data
MODE (Display Mode)
UPDATE (Update Mode)
TCODE (Transaction to be called)
BDC_INSERT
Inserts the BDC scenario in the session
TCODE (Transaction to be called)
BDC techniques used in programs:
1) Building a BDC table and calling a transaction,
2) Building a session and a set of BDC scenarios and keeping the session available in SM35,
3) Building a session and lauching the transaction right after closing the session.
-
BDC using Call Transaction
BDC using Call transaction involves calling an SAP transaction in back ground from within the ABAP
program. The process involves building an Internal BDC table containing the screen information needed to
execute the required transaction and then passing this to the Call transaction command (See code example).
The full procedure for creating a BDC program is as follows:
-
What is the difference between batch input and call transaction in BDC?
Session method.
1) synchronous processing.
2) can tranfer large amount of data.
3) processing is slower.
4) error log is created
5) data is not updated until session is processed.
Call transaction.
1) asynchronous processing
2) can transfer small amount of data
3) processing is faster.
4) errors need to be handled explicitly
5) data is updated automatically
-
BATINPUT/DIRECT INPUT
-
A: Batch-inputs can not be used to fill the "delivery due list" screen because it is not a dynpro. This is a standard SAP report. A SAP report (check with "System -> Status") may be called using SUBMIT sentence with the appropriate options . It is preferred to call a report than create a Batch-input program.
GO THROUGH THIS LINK
http://www.guidancetech.com/people/holland/sap/abap/zzsni001.htm
Go through the following Code
report Z_CALLTRANS_VENDOR_01
no standard page heading line-size 255.
Generated data section with specific formatting - DO NOT CHANGE ***
data: begin of it_lfa1 occurs 0,
KTOKK like lfa1-ktokk,
NAME1 like lfa1-name1,
SORTL like lfa1-sortl,
LAND1 like lfa1-land1,
end of it_lfa1.
End generated data section ***
data : it_bdc like bdcdata occurs 0 with header line.
*DATA: IT_MESSAGES TYPE TABLE OF BDCMSGCOLL WITH HEADER LINE.
*DATA: LV_MESSAGE(255).
data : it_messages like bdcmsgcoll occurs 0 with header line.
data : V_message(255).
data : V_flag.
data : V_datum1 type sy-datum.
data : begin of it_mesg occurs 0,
message(100),
end of it_mesg.
*V_datum1 = sy-datum-1.
parameters : P_Sess like APQI-GROUPID.
start-of-selection.
perform Get_data.
*perform open_group.
loop at it_lfa1.
perform bdc_dynpro using 'SAPMF02K' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RF02K-KTOKK'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02K-KTOKK'
it_lfa1-KTOKK.
perform bdc_dynpro using 'SAPMF02K' '0110'.
perform bdc_field using 'BDC_CURSOR'
'LFA1-LAND1'.
perform bdc_field using 'BDC_OKCODE'
'=UPDA'.
perform bdc_field using 'LFA1-NAME1'
it_lfa1-name1.
perform bdc_field using 'LFA1-SORTL'
it_lfa1-sortl.
perform bdc_field using 'LFA1-LAND1'
it_lfa1-land1.
call transaction 'XK01' using it_bdc
mode 'N'
update 'S'
messages into it_messages.
if sy-subrc <> 0.
if V_flag <> 'X'.
perform open_group.
V_flag = 'X'.
endif.
perform bdc_transaction. "using 'XK01'.
endif.
perform format_messages.
refresh : it_bdc,it_messages.
.
endloop.
if V_flag = 'X'.
perform close_group.
endif.
&----
*& Form Get_data
&----
text
----
--> p1 text
<-- p2 text
----
FORM Get_data .
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'C:\srinu_vendor.txt'
FILETYPE = 'DAT'
TABLES
DATA_TAB = it_lfa1
EXCEPTIONS
CONVERSION_ERROR = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " Get_data
&----
*& Form bdc_dynpro
&----
text
----
-->P_0061 text
-->P_0062 text
----
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR it_BDC.
it_BDC-PROGRAM = PROGRAM.
it_BDC-DYNPRO = DYNPRO.
it_BDC-DYNBEGIN = 'X'.
APPEND it_BDC.
ENDFORM.
----
Insert field *
----
FORM BDC_FIELD USING FNAM FVAL.
CLEAR it_BDC.
it_BDC-FNAM = FNAM.
it_BDC-FVAL = FVAL.
APPEND it_BDC.
ENDFORM.
&----
*& Form format_messages
&----
text
----
--> p1 text
<-- p2 text
----
FORM format_messages .
loop at it_messages.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = it_messages-MSGID
LANG = 'EN'
NO = it_messages-MSGNR
V1 = it_messages-MSGV1
V2 = it_messages-MSGV2
V3 = it_messages-MSGV3
V4 = it_messages-MSGV4
IMPORTING
MSG = V_message
EXCEPTIONS
NOT_FOUND = 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.
write : / V_message.
clear : V_message.
endloop.
ENDFORM. " format_messages
&----
*& Form open_group
&----
text
----
--> p1 text
<-- p2 text
----
FORM open_group .
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = P_Sess
HOLDDATE = V_datum1
KEEP = 'X'
USER = SY-UNAME
.
IF SY-SUBRC = 0.
write : / 'Session Creating wit Name : ',P_Sess.
ENDIF.
ENDFORM. " open_group
&----
*& Form close_group
&----
text
----
--> p1 text
<-- p2 text
----
FORM close_group .
CALL FUNCTION 'BDC_CLOSE_GROUP'.
ENDFORM. " close_group
&----
*& Form bdc_transaction
&----
text
----
-->P_0132 text
----
FORM bdc_transaction. "USING VALUE(P_0132).
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'XK01'
POST_LOCAL = NOVBLOCAL
PRINTING = NOPRINT
SIMUBATCH = ' '
CTUPARAMS = ' '
TABLES
DYNPROTAB = it_bdc
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN = 2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 6
OTHERS = 7
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " bdc_transaction
Regards
Sreeni