Vous êtes sur la page 1sur 29

BY MR.

BABU (OASIS TECHNOLOGIES)


File Handling Techniques
Introduction:

 These techniques are used to upload the data from the specified file path from legacy
system into an internal table of the programs.
 They are also used to download data from an internal table of program into the
specified file path of Legacy system.
 There are 2 types of file handling techniques:
a. Front End System/Local PC
b. Application Server -AL11

a. Front End System/Local PC:

Upload: The System provided standard function modules GUI_UPLOAD/WS_UPLOAD/UPLOAD


is used to upload data from the specified path of Local PC into an internal table of programs.

Download: The standard function modules GUI_DOWNLOAD/WS_DOWNLOAD/DOWNLOAD is


used to download the data from an internal table into the specified file path of the front end
system (Local PC).

Note:
 Files from Local PC cannot be processed in back ground since standard FMs give run
time errors.
BY MR. BABU (OASIS TECHNOLOGIES)
 The function module which starts with GUI* are advisable since it has a Delimiter
parameter (Has field separator) and support any format from ECC6.0
 The function modules UPLOAD and DOWNLOAD are outdated.
 The standard function module “ALSM-EXCEL_TO_INTERNAL_TABLE” is used to upload
the excel file data into an internal table.

F4_FILENAME Function Module:

 It is used to provide the search help to select the required file path of the Front end
system/Local PC.
Example:
AT SELECTION SCREEN ON VALUE-REQUEST FPR <P_FILE>.
CALL FUNCTION ‘F4_FILENAME’
EXPORTING
Program_name = sy-repid.
Dynpro_number = sy-dynnr.
Field_name = <‘P_FILE’> “only in uppercase
IMPORTING
file_name = <P_FILE>

Here <P_FILE> is a parameter to enter file path.

MOVE-CORRESPONDING and INTO CORRESPONDING Statements:

 This statement is used to move corresponding field data from the source to the
destination work areas or field symbols and internal tables.

Syntax: MOVE-CORRESPONDING <wa_source> TO <wa_destination>. “ While processing
SELECT <f1>
<f2>
…..
INTO CORRESPONDING FIELDS OF TABLE <gt_itab> …. “ While Extracting

Figure: Source to Destination


BY MR. BABU (OASIS TECHNOLOGIES)
Note:
 In the real time these statements are not advisable since it consumes more time to
search for the relevant similar field in destination structure or internal table

Demo Program on handling files in presentation server is “ZFILE_HANDLING_PC”

b. Application Server:

 It is used to maintain files securely.


 The Transaction Code ‘AL11’ is used to work with Application Server.
 It can be used to handle files in background.

Download / Transfer:

 The below ABAP statements are used to transfer the data from an internal table into the
specified file path of application server (AL11).
1. OPEN DATASET FOR OUTPUT….
2. TRANSFER …..TO
3. CLOSED DATASET…

1. OPEN DATASET ….FOR OUTPUT:

 This statement is used to open the required files in write mode in Application server.
Syntax:
OPEN DATASET <p_file> FOR OUTPUT IN TEXT/BINARY MODE ENCODING DEFAULT [MESSAGE
<gv_msg_text>]
2. TRANSFER Statement:

 This statement is used to transfer the concatenated data (String Line-gv_line) into the
opened file.
Syntax:
LOOP AT <gt_final> INTO <wa_final>.
*Convert numeric data into Character.
<gv_char> = <gv_numeric>. “ Convert Number type
WRITE <wa_final-currencyt> TO <gv_amnt_c>. “ Convert Currency data type
*Concatinate the data
CONCATENATE <wa_final.field> ----<gv_char> <gv_amnt_c>
INTO <gv_line>.
BY MR. BABU (OASIS TECHNOLOGIES)
*Transfer the concatenated data
TRANSFER <gv_line> TO <P_File>.
CLEAR <gv_line>.
END LOOP.
3. CLOSED DATASET Statement:

 It is used to close the opened file in the server.


Syntax:
*Open File
…..
*Transfer File
…..
*Close Opened File
CLOSE DATASET <P_File>

Upload:

 The below ABAP Statements are used to read or upload data from the file in an
application server into an internal table of the program.
1. OPEN DATASET.. FOR INPUT
2. READ DATASET
3. CLOSE DATASET

1. OPEN DATASET …FOR INPUT:

 This statement is used to open files in read mode.


Syntax:
OPEN DATASET <P_File> FOR INPUT IN TEXT/BINARY MODE [ENCODING DEFAULT MESSAGE
<gv_msg.text>]

Note:

1. An additional statement ENCODING DEAFAULT must be used encode file format in


ECC6.0 since it is Unicode system.
2. An additional statement ‘MESSAGES’ is used to capture the messages (errors) into a
string variable.

2. READ DATASET:
BY MR. BABU (OASIS TECHNOLOGIES)
 This statement is used to read record by record (line by line) from the opened file in
Application Server.

Syntax:
DO.
*Read Record by record.
READ DATASET <P_File> INTO <wa_final>.
IF sy-subrc EQ 0.
*Append Internal Table
APPEND <wa_final> TO <gt_final>.
ELSE.
*Exit out of the loop.
EXIT.
ENDIF.
CLEAR: <wa_final>.
ENDDO.

3. CLOSE DATASET:

 This statement is used to close the opened file.

Demo Program on handling files in application server is “ZFILE_HANDLING_SERVER”

Providing Search Help on the Application Server(AL11):

 The standard function modules “F4-DXFILENAME_TOPRECURSION” (or)


“/SAPDMC/LSM-F4-SERVER-FILE” is used to provide search help to choose the file path
in an application server.

The Functionality of File Handling in the server is as below:

1. Download or Transfer:
BY MR. BABU (OASIS TECHNOLOGIES)

2. Upload:

Steps to open the file in an application server (AL11):

 Execute the transaction code AL11.


 Double click on the appropriate required directory.
 Double click on the required transferred filename to see the data.

Download the files from an application server:

 The transaction code CG3Y is used to download the files from an application server into
the presentation server or front end system or local pc.

Steps to download the file from an Application Server:

 Execute the transaction code CG3Y.


 Enter the source file name (example: download.txt) in an application server.
 Select the target file name on the front end system by pressing ‘F4’.
 Click on download icon (Shift+F1).
 Click on cancel (F12).

Upload the files into an Application Server:

 The transaction code ‘CG3Z’ is used to upload files from the presentation server / front
end system / Local PC into an application server (AL11).

Steps to Upload:

 Execute the transaction code ‘CG3Z’.


 Enter the source file name on the front end system.
 Enter the target file name in an application server.
 Select the required data format (BIN/ASC).
BY MR. BABU (OASIS TECHNOLOGIES)
 Click on upload icon (shift + F2).

Note:
 Make sure the directory in an application server is not opened while writing /
transferring the data.
 The transaction code ‘FILE’ is used to maintain logical and physical file paths.
 The standard function module ‘FILE_GET_NAME’ can be used to get the logical file
path of the physical file.

Steps to maintain the physical and logical file paths:

 Execute the transaction code ‘FILE’ and click ‘Yes’ button.


 Double click on the folder ‘Assignment of Physical Paths to Logical Paths’.
 Click on ‘New Entries’ button.
 Maintain logical and physical path details.
 Example: Logical File – ZFILE_NAME
Physical File – D:/USR/SAP/ECE…….-Path from AL11.
 Click on ‘Save’ icon.
 Create the ‘T.R’ if required.
 Click on ‘Yes’ button.

Data migration/conversion
Introduction:

 This concept is used to migrate or convert a flat file data from the legacy system into sap
data base.
 Following are the different methods or techniques to migrate or convert the
Flat file data.
1. LSMW (Legacy system migration work bench).
2. BDC (Batch data communication).
3. Using standard BAPI (Business application programming interface).
4. Direct input method using standard programs.

The functionality of data migration/conversion is as below:

[DIAGRAM]-Refer Notes
BY MR. BABU (OASIS TECHNOLOGIES)
SD Flow and MM flow:

Refer Notes

LSMW (Legacy system migration work bench):

 It is the system provided tool to migrate/convert a flat file data from the legacy system
into sap data base.
 The legacy system data can be imported in different import methods using LSMW.
 The T-code LSMW is used work with LSMW
 Following are different import methods:
a) Standard batch or direct input.
B) Batch input recording.
c) Business object method (BAPI).
d) IDOC (Intermediate document).

NOTE:
 An import method batch input recording is mostly used with LSMW.

Steps to work with LSMW

 Execute the t-code LSMW.


 Click on yes button.
 Enter project name, subproject name, object name.
 Click on create entry icon.
 Click on yes button.
 Click on create entry icon.
 Enter short description for project.
 Press ‘Enter’ button.
 Enter short description for sub project.
 Press the ‘Enter’ button.
 Enter name for object.
 Click on yes button.
 Click on execute icon.

NOTE: All the process steps can be performed (14-17) are appeared.

STEP-1: Maintain Object Attributes:


BY MR. BABU (OASIS TECHNOLOGIES)
 This step is performed to select any one of the different import methods. Such are,
batch input recording /BAPI/IDOC,etc.

Steps to perform Maintain Object Attributes:

 Click on execute icon.


 Click on display/change button.
 Select radio button “batch input recording”.
 Enter the recording name.
 Click on recordings over view icon that appears beside the recording field.
 Click on create recording.
 Enter the recording name.
 Enter short description.
 Click on yes button.
 Enter the required transaction code as per the specification.

NOTE: In the real time the functional transactional codes screen fields recordings can be done
By functional consultants.
 Click on ‘Yes’ button.
 Enter valid from ____ to _____ .
 Enter cost center.
 Press ‘Enter’ button.
 Fill all the required mandatory fields such are: name, person responsible, hierarchy area,
company code and profit center.
 Click on save icon.------- Related to “ks01”.
 Click on save icon to save the recording.
 Double click on the screen field(csksz-kokrs).
 Remove the default values.
 Enter the field name.
 Click on yes.

NOTE: Follow the similar steps for any number of screen fields to which the data to be
Transferred from the flat file.
Example:
Screen field Default value Name
Csksz-kokrs Kokrs
Csksz-kostl Kostl
Csksz- 18:03:2014
dbtab_anb
Csksz-ktext Kyext
BY MR. BABU (OASIS TECHNOLOGIES)
Csksz-verak Verak.

 Click on save.
 Click on back.
 Click on back.
 Click on save icon to save maintain attributes step.
 Click on back.

STEP-2:Maintain Source Structures:

 This step is preformed to maintain the structure name of the flat file.

Steps to perform:

 Click on execute icon.


 Click on display/change icon.
 Click on create structure icon.
 Enter the source structure name and description.
 Click on yes button.
 Click on save.
 Click on back.

STEP-3: Maintain Source Fields:

 It is performed to maintain the fields of the source structure to hold the flat file data.

Steps to perform:

 Click on execute icon.


 Click on display/change icon.
 Place the cursor on source structure name.
 Click on create field icon.
 Enter field name (kostl), field length, field type.
 Click on yes button.

NOTE:
 Refer the given flat file (or) DBTAB to know field type and length.
 The field type “character” is mostly used to define the source fields.
BY MR. BABU (OASIS TECHNOLOGIES)

NOTE: Follow the similar steps for any number of source fields.

Source fields Data type Length


Kokrs C 4
Kostl C 4
Ktext C 6
Verak C 6
Prctr C 4

 Click on save icon.


 Click on back icon.

STEP-4: Maintain Structure Relations:

 This step is performed to maintain the relationships with the BDC structure.

NOTE: This step is performed by the system automatically, hence no need to perform this
Step manually.

STEP-5: Maintain Field Mapping and Conversion Rules:

 This step is performed to map the fields and maintain the conversations.

Steps to perform:

 Select a radio button “maintain field mapping and conversation rules”.


 Click on execute icon.
 Click on display/change button.
 Place the cursor on the regarding screen field.(KOKRS)
 Follow the similar steps to map any number of source structure fields of the flat file to
the screen fields of recording.

Recording
ZB_REC_KS01
BY MR. BABU (OASIS TECHNOLOGIES)
Ktext Source structure
Kokrs ZB_SOURCE_STRCTR
Kostl Kokrs
Verak Ktext
prctr Prctr
Kostl
Verak

NOTE: ABAP source code can also be written in “LSMW” using the change icon that appears
besides recording structure field.

 Click on save.
 Click on back.

STEP-6: Maintain Field Values, Translations, User defined Routines:

 It is performed to maintain default values, transactions and user defined routines for
the screen fields of the recording.

NOTE: This step can be skipped in case of not required to maintain any fixed values and
Translations.

STEP-7: Specify Files:

 It is performed to specify the flat file and the data separators from which the data to be
migrated.

Steps to perform:

 Select a radio button ‘Specify files’.


 Click on execute icon.
 Place the cursor on the required file location or directory.
 Click on display/change icon.
 Click on create icon select the required flat file by pressing f4.
 Click on open button.
 Enter flat file name.
 Select an appropriate “delimiter” such are: coma,tabular,blanks,……
 Click on yes button.
BY MR. BABU (OASIS TECHNOLOGIES)
 Double click on the imported and converted data to reduce the file length in case of file
length exceeds 45 characters.

NOTE: Length of the file under imported and converted data should not exceed 45 characters.

 Click on save icon.


 Click on back.

STEP-8: Assign Files:

 This step is performed to assign the flat files to the source structure.

NOTE: This step is performed by the system automatically hence it can be skipped.

STEP-9: Read data:

 It is performed to read the data from the uploaded flat file.


Steps to perform:

 Select the radio button “read data”.


 Click on execute icon.
 Click on execute.
 Click on back.
 Click on back.

STEP-10: Display Read Data:

 It is used to display the uploaded data of a flat file.

Steps to perform:

 Select a radio button “display read data.


 Click on execute icon.
 Click on yes button.
 Click on back after displayed data is cross checked with the flat file.

STEP-11: Convert Data:

 It is performed to convert the uploaded data of the flat file.

Steps to perform:
BY MR. BABU (OASIS TECHNOLOGIES)
 Select a radio button “convert data”.
 Click on execute icon.
 Click on execute.
 Click on back.
 Click on back.

STEP-12: Display Converted Data:

 This step is performed to display the converted data of a flat file.

Steps to Perform:

 Select a radio button “Display Converted Data”.


 Click on execute icon.
 Click on yes button.
 Click on back.

STEP-13: Create Batch Input Session:

 This step is performed to create a batch input session which can be processed to
migrate the converted flat file data into data base tables through screens.

Steps to Perform:

 Select a radio button “Create Batch Input Session”.


 Click on execute.

NOTE: The check box “Keep Batch Input Folders” can be checked to keep the processed
session in the system, otherwise the processed session is deleted by the system
automatically.

 Check the check box “keep batch input folders”.


 Click on execute icon.
 Click on yes button.

STEP-14:Run Batch Input Session:

 It is performed to run the Created batch input session to migrate or update the data
through the screens of the t-codes.
BY MR. BABU (OASIS TECHNOLOGIES)
Steps to Perform:

 Select a radio button “Run Batch Input Session”.


 Click on execute icon.
 Select the created batch input session name.
 Click on process button.

NOTE: The button “log” is used to analyze the created log file while migrating the data.

 Click on process button again.


 Keep on processing enter until all the records of the flat file are migrated.
 Click on session overview button.

NOTE: Tick mark is appeared for all the processed sessions under status column.

BDC(Batch Data Communication):

 It is a utility to develop programs /reports to migrate or convert the flat file data into the
data base tables.
 The BDC has two methods.

a)Session method.
b) Call transaction method.

Session Method:

 In case of session method the data is updated in synchronous mode only.


 The standard function module “BDC_OPEN GROUP”, “BDC_INSERT”,
“BDC_CLOSE_GROUP” are used to work with session method
 The system generates one log file while processing the created batch input session.
 The t-code SM35 is used to check or process the over view of the batch input session.

1) BDC_OPEN_GROUP Function Module:

 This function module is used to create or open the batch input session which can be
processed using the t-code SM35.
 The below parameters can be passed:
CALL FUNCTION ‘BDC_OPEN_GROUP’
EXPORTING
*client = sy-mandt “system client number.
Group = <p_group> “session name to be created in SM35.
BY MR. BABU (OASIS TECHNOLOGIES)
keep = ‘X’ “Xkeep the processed session in SM35.
*user = sy_uname “user name who executed the program .
*prog= sy_cprog “ system program name.

* indicates optional.

2)BDC_INSERT Function Module:

 This function module is used to insert the screen table data of the structure ”BDCDATA”
with Transaction into session.
 The screen table (GT_BDCDATA) can be processed to migrate the corresponding data
into data base tables through the specified t-code by processing the created session.
 The below parameters can be passed:
CALL FUNCTION ‘BDC_INSERT’
EXPORTING
T-code = ‘<t-code>’ “required functional t-code.
*CTUPARMS =<wa_ctu_parms> “handles screen resolution of table control in session.
TABLES
Dynprotab =<gt_bdcdata> “screen table of type bdc data with flat fuile data.

NOTE: An export parameter “CTUPARMS” is used to handle the screen resolution in case of
table control to process the multiple line items in session method.

3) BDC_CLOSE_GROUP Function Module:

 This function module is used to close the opened batch input session.
 No need to pass any parameters to this function module.

4) Call Transaction Method:

 It is used to update / migrate/ convert the data in both synchronous and asynchronous
mode from flat file into data base tables through screens.
 This method is faster than the session method.
 The ABAP statement “CALL TRANSACTION” is used to work with this method.

Synatx:
CALL TRANSACTION ‘<TCODE>’ USING <GT_BDCDATA> MODE
BY MR. BABU (OASIS TECHNOLOGIES)
<A/N/E>UPDATE<S/A>[messages into <gt_bdcmsgcoll>].
Here:

 <TCODE> is the required transaction code through which the flat file data to be
migrated/converted.
 <gt_bdcdata> is an internal table of type “bdc data” structure.
 <A/N/E> are different data process modes.
A = All screens.
N = No screens.
E = Error screens.
 <S/A> are the different update modes.

S = Synchronous mode.
A = Asynchronous mode.

 <gt_bdcmsgcoll>is an internal table of the type “bdcmsgcoll” structure.

NOTE: The screen resolution of the table controls is maintained in call trans action method
using the below
Syntax:
CALL TRANSACTION ‘<TCODE>’USING<GT_BDCDATA> OPTIONS FROM
<wa_ctu_params>[Message INTO <gt_bdcmsgcoll>].
Here:
<wa_ctu_params> is a structure data variable of the type “CTU_PARMS” DDIC structure.

Different data process Modes in Call Transaction Method:

 Following are the different modes to process the data in call transaction method.

I. A-All Screens:

 This data process mode displays all the screens while migrating/converting a flat
file data.

II. N-No Screens:

 This data process mode is used to process the data without showing any screens
(background).

III. E-Error screens:


BY MR. BABU (OASIS TECHNOLOGIES)
 This data process mode is used to display the error screens while processing the
data.

IV. P-Process Mode:

 It is almost similar to no-screens mode. But only the difference is the no-screens
mode does stop the break points in called transactions. Whereas the process mode
stops at the break points.

Different data Update Modes:

 There are 3modes to update the data into data base tables through the required t-code
screens.

a.)S-Synchronous Mode:

 It is used to update/migrate the data by giving an acknowledgement.


 In case of this mode the data is not continuously updated/migrated in case of error
records.

Ex: railway system, courier,……

b.) A-Asynchronous Mode:

 It is used to update/migrate the data continuously by skipping the error records.


Ex: roadtransport,normalpost,……

NOTE: The synchronous update mode is stopped with an error record whereas the
asynchronous mode skips the error records.

c.)L-Local Update:

 It is used to update/migrate the data with local update task.(Set update task local).

Some of the useful fields in BDCDATA structure:

Field Description
BY MR. BABU (OASIS TECHNOLOGIES)
Program BDC module pool
DYNPRO BDC screen number
DYN BEGIN BDC screen start
FNAM Field name
FVAL BDC field value(flat file).

Common Steps involved in BDC:

 Record screen flow of the required functional t-code using the t-code “SHDB”.

NOTE: In the real time screen flow recording is mostly given by the functional consultants.

 Convert the recorded screen flow into a temporary program.


 Upload flat file data into an internal table.
 Convert/translate/validate the uploaded flat file data within the loop of flat file internal
table (gt_flat_file).
 Copy the system generated subroutines which start with “BDC_DYNPRO” (screen no)
and “BDC_FIELD” from the temporary program of the recording which has been
generated by the system with in the loop of flat file internal table.
 Comment screen default values and pass the flat file data.
 Use any one of either session/call transaction to update/migrate the data.

Screen flow Recording -SHDB

 The t-code SHDB is used to record the screen flow as the t-codes.

Steps to Record Screen flow:

 Execute t-code SHDB.


 Click on create new recording button.
 Enter recording name.
 Enter the required t-code Ex: VA02.
 Click on start recording button.
 Enter order number ex:4970
 Press enter button.
BY MR. BABU (OASIS TECHNOLOGIES)
 Click on yes button.
 Change the required fields.
 Click on save icon.
 Click on yes button.
 Click on save icon.]Related to VA02.
 Click on save icon to save the recordings.
 Click on process button.
 Check the recording.

NOTE: An icon export is used to download the recording into local pc.

 An icon import is used to upload the recording file into an transaction recorder.
 Keep on pressing enter button until the recording process is done.
 Click on back.

Steps to Convert Recording Into Temporary Program:

 Execute t-code SHDB.


 Enter the required recording name.

NOTE: Use * symbol to list out all the recordings in a system.


 Select the required recordings, click on create program button.
 Enter temporary program name Ex: YTEMP_REC.
 Select a radio button transfer from recording.

NOTE: An option read from file is used to generate a program using the given recording file.

 Click on yes button.


 Enter title.
 Click on source code button.
 Click on local object button.
 Copy the system generated sub routine which starts with bdc_dynpro and bdc_field.
 Paste them with in the loop of a flat file internal table in the original program bdc.
 Comment default values of a screen field.
 Pass the data from flat file internal table.

Scenario on BDC:

Change the sales document data using the given flat file.
T-code: VA02.
BY MR. BABU (OASIS TECHNOLOGIES)
Tables: VBAK, VBAP.

Batch Input Session:

 The t-code SM35 is used to work with the created batch input session to process
session, check the log file etc.

Steps to Work with the Created Session:

 Execute t-code SM35.


 Enter the required session to be processed.

NOTE: Use * symbol to list all the sessions.

 Select the session name.


 Click on process button.
 Press the ‘Enter’ button.
 Keep on pressing enter button until the session is finished.
 Click on session overview button to check session.

NOTE:
 The button log is used to check the system generated log file analysis the
messages.
 The session can be scheduled in background to migrate the data without user
interaction using the tab “In Background”.

Steps to Check Log file and rectify errors:

 Once the session is processed select the errors session.


 Click on log button.
 Then select the created log overview.
 Click on display button/analyze session button.
 Analyze the system given message.
 Rectify the errors in flat file.

NOTE: Remove the processed records from the flat file, rectify error record then re process
Session in case of error record in session method.
 Click on back.

Demo program on BDC Session Method is ZB_MIGRATE_SESSION


BY MR. BABU (OASIS TECHNOLOGIES)
Scenario on BDC-Call Transaction Method:

Creation of banks using the given flat file.


T-code: FI01.
Tables: BNKA…..

Demo program on BDC Session Method is ZB_MIGRATE_CALL

Steps to Handle Messages in Call Transaction Method:

 Get the message details such are, message type message number into an internal table.
(gt_bdcmsgcoll) of the type BDCMSGCOLL using an addition “…..MESSAGES INTO” with
CALL TRANSACTION statement.
 Set a loop into an internal table (gt_bdcmsgcoll) of the type “bdcmsgcoll”.
 Use any of the function modules “FORMAT_MESSAGE”/ “WRITE_MESSAGE” to get the
corresponding message text, since the structure “BDCMSGCOLL” does not have any
message text field.

NOTE: The standard table “T100” can also be used to populate the message text.

 Display the populated messages with message text either list or ALV

Some of the Useful fields in DDIC structure BDCMSGCOLL:

Field name Description


TCODE BDC transaction code
DYNAME Screen program name
DYNUMB Screen number
MSGTYP Message type
MSGSPRA Message language
MSGID Message id
MSGNR Message number
MSGV1-MSGV4 Message variables.

Differences between LSMW and BDC:

LSMW BDC
1.It is system provided tool 1. It is utility to develop a program.
BY MR. BABU (OASIS TECHNOLOGIES)

2. The data can be imported in different 2. The data is processed or Migrated in batch
import methods such as batch input recording, input method only.
BAPI, IDOC.

3. It does not require any programming 3. It requires programming knowledge.


knowledge.

4. It is compatible for both large and small 4. It is compatible for small amount of data
amount of data. only.

5. The field mapping is done automatically by 5. The field mapping should be done manually.
the system.

6. It is not possible for custom 6. Can be used for custom screens or custom
screens/standard with custom fields of fields of applications also.
applications.
7. It cannot be used for new functional t-codes
7. It can be used for enjoy (new t-codes) (enjoy t-codes).
transaction codes also(ends with *N)
8. The t-code SM35 is used to develop BDC
8. The t-code LSMW is used to work with this program.
tool.

Differences between Session and Call Transaction Method:

Session Method Call Transaction Method


1. The data is updated/migrated in 1. The data is updated/migrated in both
synchronous mode only. synchronous and asynchronous modes.

2. The flat file data is processed 2. The flat file data is processed
asynchronously. synchronously.

3. The log file is generated by the system. 3. The messages should be handled explicitly
using the structure “BDCMSGCOLL”, and the
function modules “FORMAT_MESSAGE” /
“WRITE_MESSAGE”.
BY MR. BABU (OASIS TECHNOLOGIES)
4. The standard function modules 4. The ABAP statement CALL TRANSACTION is
“BDC_OPEN_GROUP”, “BDC_INSERT”, used to work with the call transaction method.
“BDC_CLOSE_GROUP” are used to work with
the session method.

5. It is not as fast as call transaction method. 5. It is faster than the session method.

6. One batch input session is created which 6. The t-codes are called for each record while
can be processed using the t-code SM35 after executing the program.
the program execution.

Table Control in BDC:

 The table control is used to update or migrate the multiple records (line items) in BDC.

Header data:
Doc No: 1
Line Items

Item no. Name


10 ABC PQR
20 MNO STU
……. ……. ….

Steps to Work with Table control in BDC:

 Record screen flow with line items using the t-code “SHDB”.

NOTE:
 Press page down in the table control to record the function code for page down.
 In the real time the recording is given by the functional consultants.
BY MR. BABU (OASIS TECHNOLOGIES)

 Convert the recording into a program using the button program.


 Make the below changes in the original main program.
i) Upload the flat file data which contains both header and item data.
ii) Split the uploaded fault file data into header and item tables, using the control
break statements.

[diagram]-Refer Notes

NOTE: The header and item data can be processed separately using the control break
statements without splitting the flat file data.

* Split Header and Item data


LOOP AT <gt_file> INTO <wa_file>.
ON CHANGE OF <wa_file-f1>.
MOVE <wa_file-f1> TO <wa_header-f1>.
APPEND <wa_header> TO <gt_header>.
ENDON.
<wa_item> = <wa_file>.
APPEND <wa_item> TO <gt_item>.
CLEAR:wa_file,
wa_header,
wa_item.
ENDLOOP.

 Set a loop to header internal table then process the header related data by copy and
paste the system generated header related subroutines from the temporary recording
program.
LOOP AT <gt_header> INTO <wa_header>.
REFRESH:<gt_bdcdata>.

* Process the header data


PERFORM bdc_dynpro………………..
PERFORM bdc_field………………..

 Set a loop to item table data to process the multiple line items.
 Make the item number dynamic by concatenating the screen field name with the screen
number.
BY MR. BABU (OASIS TECHNOLOGIES)
* Process the Line Items

LOOP AT gt_item INTO wa_item WHERE <f1> EQ <wa_header-f1>.


* Increase the Coutner to handle the Multiple Items
<gv_count> = <gv_count> + 1.

* Make Item No as Dynamic


CONCATENATE <'SCRNFLD' '(' '0' <gv_count> ')'
INTO <gv_fnam>.
PERFORM bdc_field USING 'BDC_CURSOR'
*'SCRNFLD(02)'.
<gv_fnam>.
…………………………………………

 Use the function code “p+” to handle page down in table control.
< lv_counter = lv_counter + 1.
IF lv_counter EQ <2>.
PERFORM bdc_field USING 'BDC_OKCODE'
'=P+'.
CLEAR lv_counter.
ENDIF. >
ENDLOOP.

 Use any one of methods wither BDC_INSERT(Session) or CALL TRANSACTION to migrate


or converted data from intern al table GT_BDCDATA.

NOTE: The control break statements can also be used to process header and item data
separately by avoiding nested loops.

Scenario on Handling Table Control in BDC:

Change the sales document header and item data.


T-code: VA02.
Tables: VBAK, VBAP.

Steps to handle Screen Resolution in BDC table Control:

 Declare/define a structure data variable of the type “CTU_PARAMS”.


BY MR. BABU (OASIS TECHNOLOGIES)
Example:DATA:<wa_ctu_params> TYPE ctu_params.

 Pass the required data such are default size, display mode,update mode and etc to the
defined ctu_params structure variable.

<wa_ctu_params>-updmode = <p_umode>.
<wa_ctu_params>-defsize = <gc_x>.
<wa_ctu_params>-dismode = <p_pmode>.

 Use the populated structure variable of type ctu_params (gs_ctu_params) with CALL
TRANSACTION using an addition “OPTIONS”.

CALL TRANSACTION <TCODE> USING <gt_bdcdata>


OPTIONS FROM <wa_ctu_params>

MESSAGES INTO <gt_bdcmsgcoll>.

NOTE: 1.Pass the structure (wa_ctu_params) to an export parameter ‘CTUPARAMS’ function


Module “BDC_INSERT” in case of session method.
2.

Conversion Routines:

 The conversion routines are used to convert the data from internal format to external
format and external format to internal format.
 The conversion routines are maintained at the domain level of a field.
 The standard function module which ends with “*input” and “*output” are attached to
the maintained at conversion routines.

*INPUT Function Module:

 It is used to convert the field data from external to internal format.

Example: 4970000000….4970.

*OUTPUT Function Module:

 It is used to convert the field data from internal to external format.

Example: 00000……49704970.

Steps to find Conversion routine:


BY MR. BABU (OASIS TECHNOLOGIES)
 Execute t-code se11.
 Enter the required table name/domain name.
 Click on display button.
 Double click on the required data element name.(vbeln_va).
 Double click on domain name.

NOTE: The conversion routine name is appeared in the conversion routine field in case of
available

 Double click on conversion routine name to find the attached conversion routine
function modules (*input, *output).
 Click on back.

Parallel Cursor Method:

 The parallel cursor method is advisable in case of an internal table(nested) contains


huge amount of data.

Steps to use Parallel Cursor Method:

 Read an internal table with in the loop of base internal table and get an index of current
record.

LOOP AT <gt_header> INTO <wa_header>.


*Process header data
READ TABLE <gt_item> INTO <wa_item> WITH KEY <f1> = <wa_header-f1>
BINARY SEARCH.
IF sy-subrc = 0.
<lv_index> = sy-tabix.

 Set a loop to second internal table (item table) to process from the set index(lv_index)
 Use an “EXIT” statement to come out of second loop for unmatched records.

LOOP AT <gt_item> INTO <wa_item> FROM <lv_index>. "Avoid WHERE condition


IF <wa_item-f1> NE <wa_header-f1>.
EXIT. “ Comes out of loop
ENDIF.
…………………………….Process Item data.
ENDLOOP. "KNA1 Loop
ENDLOOP.
BY MR. BABU (OASIS TECHNOLOGIES)
NOTE: In the real time parallel cursor method is advisable than normal nested loop in case of
huge amount of data.

Vous aimerez peut-être aussi