‎2007 Sep 19 10:23 AM
Hi
What is call transaction method ? what is the
syntax/procedure?
What is Session method ? what is the
syntax/procedure?
‎2007 Sep 19 10:26 AM
Go through the below links.
http://www.sappoint.com/abap/bdcconcept.pdf
http://www.sappoint.com/abap/bdcrec.pdf
http://help.sap.com/saphelp_46c/helpdata/en/fa/097140543b11d1898e0000e8322d00/frameset.htm
1. Work out the transaction you would use to create the data manually.
2. Use transaction SHDB to record the creation of one material master data.
Click the New recording button or the Menu - Recording - Create
3. Save the recording, and then go back a screen and go to the overview.
4. Select the recording and click on Edit - Create Program. Give the program a Z name, and select transfer from recording.
5. Edit the program. You will see that all the data you entered is hard-coded into the program. You need to make the following changes:
5.1 After the start-of-selection, Call ws_upload to upload the file (the excel file needs to be saved as TAB separated).
5.2 After the open-group, Loop on the uploaded data. For each line, perform validation checks on the data, then modify the perform bdc_field commands to use the file data.
5.3. After perform bdc_transaction, add the endloop.
Execute the program. It will have options to create a batch session or to process directly.
These are all my finds . Might be it will be useful to you.
Direct call of transactions, session handling:
/nxxxx This terminates the current transaction, and starts transaction xxxx
/n This terminates the transaction. This generally corresponds to pressing F15 to go back.
/nend This termiantes all separate sessions and logs off (corresponds to System - Logoff).
/nex This terminates all separate sessions and logs off immediately (without any warning!).
/oxxxx This opens a new session and starts transaction xxxx in This session.
/o This lists existing sessions and allows deletion or opening of a new session.
/i This terminates the current session (corresponds to System End
/i1, /i2,... This terminates the session with the number given.
.xyzw Fast path: 'xyzw' refers to the underlined letters in the menus. This type of navigation is uncommon and is provided more for emergencies (such as a defective mouse).
Batch
The following commands can be entered in correction mode ('Process in foreground' or 'Display errors only') when processing a batch input session:
/n This terminates the current batch input transaction and characterizes it as
/bdel This deletes the current batch input transaction.
/bend This terminates batch input processing and sets the session to Failed
/bda This switches from Display errors only to Process in foreground
/bde This switches from Process in foreground to Display errors only
ABAP/4
/h This switches into debugging mode.
/hs This switches into debugging mode and activates the debugging of system functions.
Buffer
WARNING: Resetting buffers can significantly change the performance of the entire system for a long time.
It should therefore only be used where there is a good reason tdso. As of release 3.0B system administator authorization is required (authorization object (S_ADMI_FCD). The action is noted in the system log.
/$SYNC This resets all buffers of the application server
/$CUA This resets the CUA buffer of the application server
/$TAB This resets the TABLE buffers of the application server
/$NAM This resets the nametab buffer of the application server
/$DYNP This resets the screen buffer of the application server
=================================================
BATCH DATA COMMUNICATION
About Data Transfer In R/3 System
When a company decides to implement the SAP R/3 to manage business-critical data, it usually does not start from a no-data situation. Normally, a SAP R/3 project comes into replace or complement existing application.
In the process of replacing current applications and transferring application data, two situations might occur:
The first is when application data to be replaced is transferred at once, and only once.
The second situation is to transfer data periodically from external systems to SAP and vice versa.
There is a period of time when information has to be transferred from existing application, to SAP R/3, and often this process will be repetitive.
The SAP system offers two primary methods for transferring data into SAP systems. From non-SAP systems or legacy system. These two methods are collectively called batch input or batch data communication.
1. SESSION METHOD
2. CALL TRANSACTION
3. DIRECT INPUT
Advantages offered by BATCH INPUT method:
1. Can process large data volumes in batch.
2. Can be planned and submitted in the background.
3. No manual interaction is required when data is transferred.
4. Data integrity is maintained as whatever data is transferred to the table is through transaction. Hence batch input data is submitted to all the checks and validations.
To implement one of the supported data transfers, you must often write the program that exports the data from your non-SAP system. This program, known as a data transfer program must map the data from the external system into the data structure required by the SAP batch input program.
The batch input program must build all of the input to execute the SAP transaction.
Two main steps are required:
To build an internal table containing every screen and every field to be filled in during the execution of an SAP transaction.
To pass the table to SAP for processing.
Prerequisite for Data Transfer Program
Writing a Data Transfer Program involves following prerequisites:
Analyzing data from local file
Analyzing transaction
Analyzing transaction involves following steps:
The transaction code, if you do not already know it.
Which fields require input i.e., mandatory.
Which fields can you allow to default to standard values.
The names, types, and lengths of the fields that are used by a transaction.
Screen number and Name of module pool program behind a particular transaction.
To analyze a transaction::
Start the transaction by menu or by entering the transaction code in the command box.
(You can determine the transaction name by choosing System Status.)
Step through the transaction, entering the data will be required for processing your batch input data.
On each screen, note the program name and screen (dynpro) number.
(dynpro = dyn + pro. Dyn = screen, pro = number)
Display these by choosing System Status. The relevant fields are Program (dynpro) and Dynpro number. If pop-up windows occur during execution, you can get the program name and screen number by pressing F1 on any field or button on the screen.
The technical info pop-up shows not only the field information but also the program and screen.
For each field, check box, and radio button on each screen, press F1 (help) and then choose Technical Info.
Note the following information:
- The field name for batch input, which youll find in its own box.
- The length and data type of the field. You can display this information by double clicking on the Data Element field.
Find out the identification code for each function (button or menu) that you must execute to process the batch-input data (or to go to new screen).
Place the cursor on the button or menu entry while holding down the left mouse button. Then press F1.
In the pop-up window that follows, choose Technical info and note the code that is shown in the Function field.
You can also run any function that is assigned to a function key by way of the function key number. To display the list of available function keys, click on the right mouse button. Note the key number that is assigned to the functions you want to run.
Once you have program name, screen number, field name (screen field name), you can start writing.
DATA TRANSFER program.
Declaring internal table
First Integral Table similar to structure like local file.
Declaring internal table like BDCDATA
The data from internal table is not transferred directly to database table, it has to go through transaction. You need to pass data to particular screen and to particular screen-field. Data is passed to transaction in particular format, hence there is a need for batch input structure.
The batch input structure stores the data that is to be entered into SAP system and the actions that are necessary to process the data. The batch input structure is used by all of the batch input methods. You can use the same structure for all types of batch input, regardless of whether you are creating a session in the batch input queue or using CALL TRANSACTION.
This structure is BDCDATA, which can contain the batch input data for only a single run of a transaction. The typical processing loop in a program is as follows:
Create a BDCDATA structure
Write the structure out to a session or process it with CALL TRANSACTION USING; and then
Create a BDCDATA structure for the next transaction that is to be processed.
Within a BDCDATA structure, organize the data of screens in a transaction. Each screen that is processed in the course of a transaction must be identified with a BDCDATA record. This record uses the Program, Dynpro, and Dynbegin fields of the structure.
The screen identifier record is followed by a separate BDCDATA record for each value, to be entered into a field. These records use the FNAM and FVAL fields of the BDCDATA structure. Values to be entered in a field can be any of the following:
Data that is entered into screen fields.
Function codes that are entered into the command field. Such function codes execute functions in a transaction, such as Save or Enter.
The BDCDATA structure contains the following fields:
PROGRAM: Name of module pool program associated with the screen. Set this field only for the first record for the screen.
DYNPRO: Screen Number. Set this field only in the first record for the screen.
DYNBEGIN: Indicates the first record for the screen. Set this field to X, only for the first record for the screen. (Reset to (blank) for all other records.)
FNAM: Field Name. The FNAM field is not case-sensitive.
FVAL: Value for the field named in FNAM. The FVAL field is case-sensitive. Values assigned to this field are always padded on the right, if they are less than 132 characters. Values must be in character format.
Transferring data from local file to internal table
Data is uploaded to internal table by UPLOAD of WS_UPLOAD function.
Population of BDCDATA
For each record of internal table, you need to populate Internal table, which is similar to BDCDATA structure.
All these five initial steps are necessary for any type of BDC interface.
DATA TRANSFER program can call SESSION METHOD or CALL TRANSACTION. The initial steps for both the methods are same.
First step for both the methods is to upload the data to internal table. From Internal Table, the data is transferred to database table by two ways i.e., Session method and Call transaction.
SESSION METHOD
About Session method
In this method you transfer data from internal table to database table through sessions.
In this method, an ABAP/4 program reads the external data that is to be entered in the SAP System and stores the data in session. A session stores the actions that are required to enter your data using normal SAP transaction i.e., Data is transferred to session which in turn transfers data to database table.
Session is intermediate step between internal table and database table. Data along with its action is stored in session i.e., data for screen fields, to which screen it is passed, the program name behind it, and how the next screen is processed.
When the program has finished generating the session, you can run the session to execute the SAP transactions in it. You can either explicitly start and monitor a session or have the session run in the background processing system.
Unless session is processed, the data is not transferred to database table.
BDC_OPEN_GROUP
You create the session through program by BDC_OPEN_GROUP function.
Parameters to this function are:
User Name: User name
Group: Name of the session
Lock Date: The date on which you want to process the session.
Keep: This parameter is passed as X when you want to retain session after
processing it or to delete it after processing.
BDC_INSERT
This function creates the session & data is transferred to Session.
Parameters to this function are:
Tcode: Transaction Name
Dynprotab: BDC Data
BDC_CLOSE_GROUP
This function closes the BDC Group. No Parameters.
Some additional information for session processing
When the session is generated using the KEEP option within the BDC_OPEN_GROUP, the system always keeps the sessions in the queue, whether it has been processed successfully or not.
However, if the session is processed, you have to delete it manually. When session processing is completed successfully while KEEP option was not set, it will be removed automatically from the session queue. Log is not removed for that session.
If the batch-input session is terminated with errors, then it appears in the list of INCORRECT session and it can be processed again. To correct incorrect session, you can analyze the session. The Analysis function allows to determine which screen and value has produced the error. If you find small errors in data, you can correct them interactively, otherwise you need to modify batch input program, which has generated the session or many times even the data file.
Here are examples
report ZKIRAN_UPLOAD
no standard page heading line-size 255.
include bdcrecx1.
--
tables : zkiran_tab2.
--
data : itab like zkiran_tab2 occurs 15 with header line.
--
selection-screen: begin of block a1.
parameters : i_file like rlgrap-filename default 'D:\Documents and Settings\tzj13g\Desktop\sample.txt'.
selection-screen : end of block a1.
*at selection-screen on value-request for i_file.
*CALL FUNCTION 'F4_FILENAME'
*EXPORTING
*PROGRAM_NAME = sy-repid
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
IMPORTING
*FILE_NAME = i_file.
start-of-selection.
parameters: dataset(132) lower case.
DO NOT CHANGE - the generated data section - DO NOT CHANGE ***
*
If it is nessesary to change the data section use the rules:
1.) Each definition of a field exists of two lines
2.) The first line shows exactly the comment
'* data element: ' followed with the data element
which describes the field.
If you don't have a data element use the
comment without a data element name
3.) The second line shows the fieldname of the
structure, the fieldname must consist of
a fieldname and optional the character '_' and
three numbers and the field length in brackets
4.) Each field must be type C.
*
Generated data section with specific formatting - DO NOT CHANGE ***
data: begin of record,
data element: CLASSTAB
TBMA_001(001),
data element: TABNAME16
TBMA_VAL_002(016),
data element: ZEMPNO
EMPNO_003(010),
data element: ZNAME
NAME_004(020),
data element: ZDEPTID
DEPTID_005(002),
data element: ZDESIG
DESIG_006(010),
data element: ZPLACE
PLACE_007(010),
data element: CLASSTAB
TBMA_008(001),
data element: TABNAME16
TBMA_VAL_009(016),
end of record.
End generated data section ***
start-of-selection.
perform u_itab.
perform upload_ztable.
end-of-selection.
&----
*& Form upload_ztable
&----
FORM upload_ztable .
perform open_dataset using dataset.
perform open_group.
loop at itab.
read dataset dataset into record.
if sy-subrc <> 0. exit. endif.
perform bdc_dynpro using 'SAPMSRD0' '0102'.
perform bdc_field using 'BDC_CURSOR'
'RSRD1-TBMA_VAL'.
perform bdc_field using 'BDC_OKCODE'
'=SHOW'.
perform bdc_field using 'RSRD1-TBMA'
record-TBMA_001.
perform bdc_field using 'RSRD1-TBMA_VAL'
'ZKIRAN_TAB2'.
perform bdc_dynpro using 'SAPLSD41' '2200'.
perform bdc_field using 'BDC_CURSOR'
'DD02D-TABCLTEXT'.
perform bdc_field using 'BDC_OKCODE'
'=TDED'.
perform bdc_dynpro using '/1BCDWB/DBZKIRAN_TAB2' '0101'.
perform bdc_field using 'BDC_CURSOR'
'ZKIRAN_TAB2-PLACE'.
perform bdc_field using 'BDC_OKCODE'
'=SAVE'.
perform bdc_field using 'ZKIRAN_TAB2-EMPNO'
ITAB-EMPNO.
perform bdc_field using 'ZKIRAN_TAB2-NAME'
ITAB-NAME.
perform bdc_field using 'ZKIRAN_TAB2-DEPTID'
ITAB-DEPTID.
perform bdc_field using 'ZKIRAN_TAB2-DESIG'
ITAB-DESIG.
perform bdc_field using 'ZKIRAN_TAB2-PLACE'
ITAB-PLACE.
perform bdc_dynpro using '/1BCDWB/DBZKIRAN_TAB2' '0101'.
perform bdc_field using 'BDC_OKCODE'
'/EBACK'.
perform bdc_field using 'BDC_CURSOR'
'ZKIRAN_TAB2-EMPNO'.
perform bdc_dynpro using 'SAPLSD41' '2200'.
perform bdc_field using 'BDC_CURSOR'
'DD02D-TABCLTEXT'.
perform bdc_field using 'BDC_OKCODE'
'=WB_BACK'.
perform bdc_dynpro using 'SAPMSRD0' '0102'.
perform bdc_field using 'BDC_CURSOR'
'RSRD1-TBMA_VAL'.
perform bdc_field using 'BDC_OKCODE'
'=BACK'.
perform bdc_field using 'RSRD1-TBMA'
record-TBMA_008.
perform bdc_field using 'RSRD1-TBMA_VAL'
record-TBMA_VAL_009.
perform bdc_transaction using 'SE11'.
endloop.
perform close_group.
perform close_dataset using dataset.
ENDFORM. " upload_ztable
&----
*& Form upload_itab
&----
FORM u_itab .
break-point.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
CODEPAGE = ' '
FILENAME = i_file
FILETYPE = 'DAT'
HEADLEN = ' '
LINE_EXIT = ' '
TRUNCLEN = ' '
USER_FORM = ' '
USER_PROG = ' '
DAT_D_FORMAT = ' '
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = itab
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
NO_AUTHORITY = 10
OTHERS = 11
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Program2- Updating data into table from text file
&----
*& Report YTEST
*&
&----
*&
*&
&----
REPORT YTEST.
--
TABLES : ZKIRAN_T1.
--
--
DATA : ITAB LIKE ZKIRAN_T1 OCCURS 10 WITH HEADER LINE.
--
selection-screen: begin of block b1.
parameters : p_file like rlgrap-filename default 'D:\Documents and Settings\tzj13g\Desktop\sample.txt'.
selection-screen : end of block b1.
start-of-selection.
perform upload_itab.
perform display.
-at selection-screen--
&----
*& Form upload_itab
&----
FORM upload_itab .
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
CODEPAGE = ' '
FILENAME = p_file
FILETYPE = 'ASC'
HEADLEN = ' '
LINE_EXIT = ' '
TRUNCLEN = ' '
USER_FORM = ' '
USER_PROG = ' '
DAT_D_FORMAT = ' '
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = itab
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
NO_AUTHORITY = 10
OTHERS = 11
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " upload_itab
&----
*& Form display
&----
text
----
--> p1 text
<-- p2 text
----
FORM display .
modify zkiran_t1 from table itab.
ENDFORM. " display
‎2007 Sep 19 10:29 AM
Hi Sowjanya,
I can u send u some PDF's if u wish. Anyways There's always abundant data on BDC whenever you logon to SDN.
Regards,
Sai
‎2007 Sep 19 10:30 AM
Hi,
In ur abap editor in program just type 'call transaction' single click on it and press F1.....The ABAp keyword document will provide u all the infor..
Same is the case with session method
‎2007 Sep 19 10:31 AM
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
*************************************************
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
************************************************
Regards
Vasu
‎2007 Sep 19 10:48 AM
hi,
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
ex:
call transaction is one of the methods in bdc
syntax: call transaction 'MM01' using 'itab'
options 'ctu_paramas1'
mode 'A/E/N'
update 'A/S'
MESSAGES INTO MESSTAB.
where
itab -
internal table which contains data so that that dat should be populated into transaction MM01.
options -
its optional mainly useful for maintaining the screen resolutions consistency for any type of monitors......
mode -
mode is of 3 types of screens are displayed as
1. error screen
2. no screen
3. all screen
while ipdating data into the transaction 'MM01'
update -
can be done in two ways
1. synchronous -
do all or nothing
2. asynchronous -
step by step
messtab -
which contains all the error messages while doing updation.
ex:
session method:
in coding part after recording we hav to call three function module - BDC_OPEN_GROUP
BDC_INSERT
BDC_CLOSE_GROUP
and we have to create a internal table like BDCDATA as
data:it_bdcdata like bdcdata occus 0 with header line.
which contains fields like
1. fnam -
name of field
2. fval -
value of the field
3. dynbegin -
starting of the screen
4.dynscr -
screen no
5. program -
program name.
if helpful reward some points.
with regards,
Suresh Aluri.
‎2007 Sep 19 10:55 AM
CALL TRANSACTION <TCODE> USING <BDCTAB>
MODE <A/N/E>
UPDATE <S/A>
MESSAGES INTO <MSGTAB>.
A ALL SCREEN MODE. ALL THE SCREEN OF THE TRANSACTION ARE DISPLAYED.
N NO SCREEN MODE. NO SCREEN IS DISPLAYED WHEN YOU EXECUTE THE TRANSACTION.
E ERROR SCREEN. IF THE SCREEN HAS ERROR RECORD, THEN THAT SCREEN WILL BE DISPLAYED.
S - IF YOU CHANGE DATA OF ONE TABLE THEN ALL THE RELATED TABLES GETS UPDATED. AND SY-SUBRC IS RETURNED I.E., SY-SUBRC IS RETURNED FOR ONCE AND ALL.
A - WHEN YOU CHANGE DATA OF ONE TABLE, THE SY-SUBRC IS RETURNED. AND THEN UPDATING OF OTHER AFFECTED TABLES TAKES PLACE. SO IF SYSTEM FAILS TO UPDATE OTHER TABLES, STILL SY-SUBRC RETURNED IS 0 (I.E., WHEN FIRST TABLE GETS UPDATED
IMPORTANT POINTS IN CALL TRANSACTION METHOD:
1) IMMEDIATE UPDATION IN DATABASE TABLE.
2) SY-SUBRC IS RETURNED.
3) ERRORS NEED TO BE HANDLED EXPLICITLY.
4) UPDATION IN DATABASE TABLE CAN BE SYNCHRONOUS OR ASYNCHRONOUS.
5) SYNCHRONOUS PROCESSING.
6) TRANSFERS DATA FOR MULTIPLE TRANSACTIONS.
<b>PLEASE REWARD IF USEFUL....</b>