BDC Technology (example)

Source: Internet
Author: User
BDC Technology

BDC (batch data conversion): in the SAP system, for some reason, you may need to input data repeatedly (data is different, but operations are the same, A typical scenario is that the data of the old system needs to be imported to sap when switching the system. The general process is like this: enter a t-code,
Enter a screen, enter a value (sometimes add some additional checkbox options), and click the execute or OK button,
Enter another screen, enter values in some fields (or mark checkbox selected or not selected), or modify values in these fields.
Then press "eneter "......
Finally, press "save "......,
After a record is completed, continue with the next record.

In the above case, if a "person" is used, it may not be enough. But it is very easy for computers.

SAP uses a specialProgram(T-code: shdb) records all the processes of a user's business operation.

Input the transaction code (transactionCode), Click "Start recording" to start. It is a common business operation for the user, but sap is recording:
1. The field to which the cursor is placed (do not change it in the Program)
2. What value is filled in? (variable, an internal table field in the loop)
3. What button is clicked (do not change it in the Program)

As a "representative", this operation is a "template" that tells the SAP system how to execute the program, that is to say, the computer language is used to describe the process of manual operations.

To program with BDC technology, follow these steps:
1. Read external data sources (such as TXT and Excel) into the internal table or use do enddo loop.
2. in the loop, repeat the steps recorded with shdb for n times. (n = the number of dialog screens) at this time, the data is not actually imported. The system just fills in the table ", enter an internal table called "bdcdata.
Call transaction 'xxxx' using BDC ...... This command is used to create a session for a real commit action or call function 'bdc _ insert. And return the execution result to the internal table messtab.

Now let's assume a situation to make a demo of the BDC program.
Due to business needs, a company intends to add the specified text group X to the descriptions of some materials. Therefore, we need to modify the existing material data using t-code: mm02,

External data is TXT text, with N records, as shown below:

Material No. Description
6000-00001 xxxxxxx (Group)
2098-00001 fdfladsfladfl (Group B)
2059-00009 dfdsfreddfalfasfa (Group)
2003-00003 iadfdafdf, adfasf (Group D)
......
......
In the command bar, enter T-code: shdb To Go To The following screen:

Click new recodring. The following screen is displayed:

The recording name is random. Mm02 is the transaction code to be recorded.

Press "Start recording" to enter "change material". In this case, the following operation is a normal material description modification operation for the user, although the system records all the operations.

Enter an item and click "select View (s )"

Suppose we only select "basic data 1" and "basic data 1"
Then click the green tick "enter"

We add a "group A" after the material, and the description is changed:
......

Click "save" to save the modification.

Now sap has returned to shdb,

Click "save", save recording: ztest, and then click "back" to return the first screen of shdb.

Select "ztest" and click "program". SAP automatically generates a program.
In the dialog box above, enter the program name (note the sap naming rules, starting with Y or Z) and confirm the input.

Enter the property information of some programs as follows:

Click "source code" and specify "develop class" to enter the ABAP editor and generate the following code:

Report zbdctest
No standard page heading line-size 255.

Include bdcrecx1.

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
* Comment without a data element name
* 3.) The second line shows the fieldname of
* Structure, the fieldname must consist
* 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: matnr
Matnr_001 (018 ),
* Data Element: xfeld
Kzsel_01_002 (001 ),
* Data Element: xfeld
Kzsel_02_003 (001 ),
* Data Element: maktx
Maktx_004 (040 ),
* Data Element: Meins
Meins_005 (003 ),
* Data Element: mtpos_mara
Mtpos_mara_006 (004 ),
* Data Element: gewei
Gewei_007 (003 ),
End of record.

* ** End generated data section ***

Start-of-selection.

Perform open_dataset using dataset.
Perform open_group.

Do.

Read dataset into record.
If sy-subrc <> 0. Exit. endif.

Perform bdc_dynpro using 'saplmgmm' '000000 '.
Perform bdc_field using 'bdc _ cursor'
'Rmmg1-matnr '.
Perform bdc_field using 'bdc _ okcode'
'= Ausw '.
Perform

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.