October 23rd, 2009

ALE TCODE and program

No Comments, T-CODE, by Jack.

Transaction Codes:
SALE – IMG ALE Configuration root
WE20 – Manually maintain partner profiles
BD64 – Maintain customer distribution model
BD71 – Distribute customer distribution model
SM59 – Create RFC Destinations
BDM5 – Consistency check (Transaction scenarios)
BD82 – Generate Partner Profiles
BD61 – Activate Change Pointers – Globally
BD50 – Activate Change Pointer for Msg Type
BD52 – Activate change pointer per change.doc object
BD59 – Allocation object type -> IDOC type
BD56 – Maintain IDOC Segment Filters
BD53 – Reduction of Message Types
BD21 – Select Change Pointer
BD87 – Status Monitor for ALE Messages
BDM5 – Consistency check (Transaction scenarios)
BD62 – Define rules
BD79 – Maintain rules
BD55 – Defining settings for IDoc conversion

WEDI – ALE IDoc Administration

WE11 – Delete IDOC

WE19 – IDOC处理的测试工具
WE21 – Ports in Idoc processing
WE63/WE60 – IDoc documentation(生成parser、C等描述,给外部程序用)
SARA – IDoc archiving (Object type IDOC)
WE47 – IDoc status maintenance
WE07 – IDoc statistics

BALE – ALE Distribution Administration
WE05 – IDoc overview
BD87 – Inbound IDoc reprocessing
BD88 – Outbound IDoc reprocessing
BDM2 – IDoc Trace
BDM7 – IDoc Audit Analysis
BD21 – Create IDocs from change pointers
SM58 – Schedule RFC Failures

Basic config for Distributed data:
BD64: Maintain a Distributed Model
BD82: Generate Partner Profile
BD64: Distribute the distribution Model

Programs:
RBDMIDOC – Creating IDoc Type from Change Pointers
RSEOUT00 – Process all selected IDocs (EDI)
RBDAPP01 – Inbound Processing of IDocs Ready for Transfer
RSARFCEX – Execute Calls Not Yet Executed
RBDMOIND – Status Conversion with Successful tRFC Execution
RBDMANIN – Start error handling for non-posted IDocs
RBDSTATE – Send Audit Confirmations

 

via http://blog.chinaunix.net/u1/40527/showart_1898711.html

Question: Could you tell me the difference between exit and stop when used in different situations like inside loop,i the program etc?

Answer:

Hi,
STOP :This statement terminates a processing block in an executable  program.
The statement is only intended for use in the INITIALIZATION, AT SELECTION-SCREEN, START-OF-SELECTION, and GET events. It  terminates the current processing block in an executable  program and triggers the END-OF-SELECTION event. In all other
processing blocks, or when you do not want to trigger the  END-OF-SELECTION event, you must use EXIT.
EXIT.
- Within a loop structure:
Terminates loop processing (DO, WHILE, LOOP, SELECT).
- Within subroutines and other modularization units (but not  in a loop structure):
Leaves the subroutine or modularization unit (FORM, MODULE,  FUNCTION, TOP-OF-PAGE, END-OF-PAGE).
- Outside loop structures and modularization units (report  processing):
Terminates report processing and triggers list display.

DATA: SAP_COUNT TYPE I,
WA_T100 TYPE T100.
SELECT * FROM T100 INTO WA_T100 WHERE SPRSL = SY-LANGU AND
ARBGB = ‘DS’.
WRITE / WA_T100-TEXT.
IF WA_T100-TEXT CS ‘SAP’.
ADD 1 TO SAP_COUNT.
IF SAP_COUNT = 3.
EXIT.
ENDIF.
ENDIF.
ENDSELECT.

via https://forums.sdn.sap.com/thread.jspa?threadID=404985&tstart=61350

How to get local print machine information? Pls check below program.

DATA: PRDEFAULT LIKE  FRPRLIST-PRNAME ,
      IS_FRONTEND LIKE  RSPOTYPE-MODE .
DATA: LIST LIKE FRPRLIST OCCURS 0 WITH HEADER LINE.
 
CALL FUNCTION 'RSPO_FRONTEND_PRINTERS_FOR_DEV'
  EXPORTING
    DEVICE               = 'LP01'
 IMPORTING
   PRDEFAULT            = PRDEFAULT
   IS_FRONTEND          = IS_FRONTEND
*   IS_MAIL              =
*   NO_CHOICE            =
 TABLES
   LIST                 = LIST[]
 EXCEPTIONS
   NO_LIST              = 1
   LIST_TRUNCATED       = 2
   NAME_NOT_FOUND       = 3
   OTHERS               = 4 .
 
WRITE: / 'DEFAULT PRINTER:' , PRDEFAULT.
SKIP.
WRITE: / 'Printer List:'.
LOOP AT LIST.
  WRITE AT /4 LIST .
ENDLOOP.

via http://blog.chinaunix.net/u1/40527/showart_1989847.html

October 22nd, 2009

SAP ABAP IDOC Steps

3 Comments, ALE & IDocs, by Jack.

What is ABAP IDOC? If you want to know about IDOC steps, pls check out below information via SDN wiki.

What is a IDOC?

An IDoc is simply a data container that is used to exchange information between any two processes that can understand the syntax and semantics of the data. IDoc is not a process.
-         IDocs are stored in the database.
-         In the SAP system, IDocs are stored in database tables.
-         IDocs are independent of the sending and receiving systems.
-         IDocs are independent of the direction of data exchange.

Creation of IDOCs

Transaction code: WE 30

Steps of Defining Segment

Creating Segment : Tcode – WE31
Creating Message Type : Tcode – we81
Assigning Message type to Idoc type: Tcode – we82

Process

The two processes for IDoc are Outbound Process and Inbound Process.

Outbound Process

When the data is sent out from the system, the process is called Outbound Process and the IDoc is known as Outbound IDoc.

Inbound Process

When the data is coming in, the process is called Inbound Process and the IDoc is known as Inbound IDoc.

Outbound Process (Sending System) Steps :

1) Goto Tcode SALE:
Creating the logical system

Click on Sending & Receiving Systems à Select Logical Systems–Here Define the Logical Systems à Click on Execute Button
Go for New Entries
1)  System Name : LOG1:Description: Sending System
2)  System Name : LOG2:Description: Receiving System
Press Enter & Save it will ask for Request if you want new request create new request or press continue for transferring the objects.
Assigning Client to the Logical System:
Select Assign Client to Logical Systems -

Client                   : Sending System
Logical System    : LOG1
and also
Client   : Receiving System
Logical System    : LOG2

Save this Data.

Step 2) For RFC Creation:
Goto Tcode SM59 and  Select R/3 Connects
Click on create Button
RFC Destination Name should be same as partner’s logical system name and case sensitive to create the ports automatically while generating the partner profiles
Give the information for required fields:
RFC Destination    : LOG2
Connection type    : 3
Target Host            : sappdc.wipro.com
System No              : 00
Client                      : 210
User                        : Login user name
Password                :
Save this & Test it and Remote Login
Step 3) Goto Tcode BD64:

Click on the change button>Click on the create model view
Short Text: model view
Technical Name: LMOD
Save this & press ok
Select just created model view
Name: “LMOD”
Goto add message type
Model Name  : LMOD
Sender           : LOG1
Receiver         : LOG2
Message type: ZAZHARMESS
Save and press Enter.

4) Goto Tcode BD82:

Give Model View   : LMOD
Partner system     : LOG2
Execute this by pressing F8
It will gives you sending system port No:  A00000000089 (Like)

5) Goto Tcode BD64:
Select the model view
Goto >Edit >model view > Distribute
Press ok & Press Enter.

Run your Zprogram
REPORT  ZIDOC1                             .
DATA: Begin of imara occurs 0,
matnr like mara-matnr,
mtart like mara-mtart,
end of imara.
DATA: wamas_con LIKE edidc,
imas_data LIKE edidd OCCURS 0 WITH HEADER LINE,
icom_con LIKE edidc OCCURS 0 WITH HEADER LINE.
PARAMETERS: e_matnr LIKE mara-matnr,
e_msgtyp LIKE edidc-mestyp,
e_rcvprn LIKE edidc-rcvprn.
* retrive app. data from DB
SELECT matnr mtart FROM mara INTO TABLE imara WHERE
matnr = e_matnr.
*Master idoc control record
wamas_con-rcvprt = ‘LS’.
wamas_con-rcvprn = e_rcvprn.
wamas_con-idoctp = ‘ZAZHARIDOC’.
wamas_con-mestyp = e_msgtyp.
* master idoc data records
LOOP AT imara.
imas_data-segnam = ‘ZAZHARSEG’.
move imara to imas_data-sdata .
APPEND imas_data.
ENDLOOP.
CALL FUNCTION ‘MASTER_IDOC_DISTRIBUTE’
EXPORTING
master_idoc_control = wamas_con
TABLES
communication_idoc_control = icom_con
master_idoc_data = imas_data
COMMIT WORK.

6) Verifying Transfer of IDOCs Tcode – we05
ALE/IDOC Status Codes (outbound):
01> IDoc Added
30 > IDoc ready for dispatch
29 >Error in ALE service Layer
12 >Dispatch ok
03 > Data passed to port ok.

Inbound Process (Receiving System) Steps:

Do the same step as you did in sending system

>  Creating IDoc
>   Defining the Segment
>   Creating Message Type
>   Assigning the Message Type
>   Defining the Logical System
>   Assigning the Logical System
>   Creating the Distribution Model
1) Goto Tcode – we57:
Assign function module to IDoc type
Module: Function module
Basic type:
Message type:
Direction: 2 (inbound)
2) Creating Inbound process code – we42
3) Verifying Idoc List Tcode – we05
4) ALE/IDOC Status Codes (Inbound):
50 > IDoc Added
51 >Application Document not posted
64 >IDoc ready to be transferred to application
62 >IDoc passed to application
53 >Application Document posted

Difference with SMARTFORMS vs. SapScript(SE71)

The Following are the differences :-

a) Multiple page formats are possible in smartforms which is not the case in SAPScripts

b) It is possible to have a smartform without a main window .

c) Labels cannot be created in smartforms.

d) Routines can be written in smartforms tool.

e) Smartforms generates a function module when activated.

f) Unlike sapscripts (RSTXSCRP), you cannot upload/download Smartform to your local harddisk.

g)sap script is client dependent,smartform is client independent.

h)sap script main window is mandotary,smartform not mandatory

i)sap script 99 main windows, smartform only one main window

j)you can post sap scripts diretely to web but this is not possible in the case of smartform.

via http://www.saptechies.com/difference-between-sapscripts-smartforms/

———————————————-

The Following are the differences

  • Multiple page formats are possible in smartforms which is not the case in SAPScripts
  • It is possible to have a smartform without a main window .
  • Labels cannot be created in smartforms.
  • Routines can be written in smartforms tool.
  • Smartforms generates a function module when activated.
    • Contributed by : SAP ABAP/4 Programming, Basis Administration, Configuration Hints and Tips
  • Unlike sapscripts (RSTXSCRP), you cannot upload/download Smartform to your local harddisk.

It was said that it was provided in CRM 3.0 version, but not available in R/3. You can download smartforms into Local PC in a XML format. In the same way you can upload this XML format into Smartform. From the smartform editor itself you can call download option, if you are working in CRM 3.0 environment.

In R3 also, you can download into XML format. However, it’s not sure about uploading. Refer to the program ‘SF_XSF_DEMO’.

In 4.7 Enterprise, other have seen this utlity which is completey missing in 4.6c. There is functionality to downlaod a complete form or only a particular node. (Utilities -> Download form). It will create a XML file and save it in the hard disk.

For others, if you want to download/upload the Smartforms source, you will need the help from the Basis people. What you can do is to create a Transport and then FTP down to your local harddisk. When you need the Smartform source in another system, you have FTP up the Smartforms file back to the SAP server. Finally, the Basis team, will tp it into your system.

The protect and endprotect command in sapscript doesn’t work with smartforms. For example on a invoice: First data of position no 80. is printed on page one, other data of position no 80 is printed on page 2. And there’s nothing you can do about it. Actually, there is something you can do about it. By using a folder node and checking the ‘protect’ checkbox, everything in that folder will be page protected.
FAQ on Migrating SAPscript to SmartForms Is it possible to migrate a SAPscript form to a Smart Form? Smart Forms provides a migration tool for this purpose which migrates layout and texts of a SAPscript form to a Smart Form. It does not migrate SAPscript form logic of the print program. Using Smart Forms, this logic is described by the tree structure of the Form Builder. The effort involved in migrating it depends on the complexity of the print program.

via http://it.toolbox.com/wiki/index.php/SAP_Smart_Forms

Question:

hi
I have to display multiple languages in same page in smartfroms
I have to display like

Customer Name: &kna1-name1&
<Customer Name in japaneese>
<Customer Name in Fench>
the output should be like
Customer Name: John Smith
Japaneese
french
The point is John Smith should be printed only in English
but ‘Customer Name’ should be in in english japaneese and french.
I am abel to copy and paste the japneese language from word sheet into text

elements but they are not getting displayed in the output.
Any help in this is greatly appreciated

I faces a similar problem but instead of using SAPScript text I used
Text Modules (which can be translated into different languages) and then
just set the Language field as a variable to the correct language. It
simplified the whole process as the Transport system will actually
transport Text Modules and the translations instead of having to
maintain the Standard Text in each system.

In TCode SMARTFORMS, click on the Text Module radio button, and enter
the name of the text module.
Enter your text in whatever language you are logged in as, save and
activate.

In TCode SE63 use menu path Translation –> R3 Enterprise –> Other Long
Text.
Select SSF (SAP Smart Forms) from the Popup box.
Enter the name of the Text Module, you created in the first step, into
the Object line.
Choose the Source language you created in and Target Language you what
to translate too.

Cut and past your text from Word and Save Active.

In the Smart Form use the Text Type ‘M’ Text Module. Enter the name of
the Text Module you created. Set the Language to be a variable and enter
the variable that holds which language you want to print in.

Hope this helps, and I find Text Modules much easier to work with then
SAPScript Text.

July 27th, 2009

ABAP Tips-ebook

No Comments, ABAP Program, by Jack.

There is ABAP Tips(eBook version) for you, if you need it , pls download it.

download_iconabap-tips

abap-tips

BSEG will contains all items data.

try to make use of this FM
AC_DOCUMENT_RECORD.
or

1
2
3
4
5
6
7
8
9
10
11
12
call function 'FI_DOCUMENT_RECORD'
exporting
i_awtyp = 'RMRP'
i_awref = w_awref1 ---&gt;IR number of PO
i_aworg = w_gjahr1----.year
 
I_AWSYS = ' '
I_AWTYP_INCL = ' '
I_AWTYP_EXCL = ' '
I_BUKRS = ' '
tables
t_documents = t_doc.

There is an ABAP program tips document(157 pages) to download. I think it is very useful for ABAP developer.

Download abap program tips-v3

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
*
* Copy Materials from one Plant to Another
* First run   GETDATA AS CHECKBOX, "Tick to download materials data to local harddisk
* Second run  UPDDATA AS CHECKBOX. "Tick to update date to Materials Master
* Check data in Excel before Second run
* 
REPORT ZBAPIMM01 LINE-SIZE 255 NO STANDARD PAGE HEADING
                 LINE-COUNT 065(001).
 
TABLES: T001L, "Storage Locations
        MARA,  "General Material Data
        MAKT,  "Material Descriptions
        MBEW,  "Material Valuation
        MARC.  "Plant Data for Material
 
DATA: BAPI_HEAD   LIKE BAPIMATHEAD,
      BAPI_MAKT   LIKE BAPI_MAKT,    "Material Description
      BAPI_MARA1  LIKE BAPI_MARA,    "Client Data
      BAPI_MARAX  LIKE BAPI_MARAX,
      BAPI_MARC1  LIKE BAPI_MARC,    "Plant View
      BAPI_MARCX  LIKE BAPI_MARCX,
      BAPI_MBEW1  LIKE BAPI_MBEW,    "Accounting View
      BAPI_MBEWX  LIKE BAPI_MBEWX,
      BAPI_RETURN LIKE BAPIRET2.
 
DATA: BEGIN OF INT_MAKT OCCURS 100.
        INCLUDE STRUCTURE BAPI_MAKT.
DATA: END OF INT_MAKT.
 
DATA: BEGIN OF INT_MAT OCCURS 100,
         WERKS(4),     "Plant
         MTART(4),     "Material type
         MATNR(18),    "Material number
         MATKL(9) ,    "Material group
         MBRSH(1),     "Industry sector
         MEINS(3),     "Base unit of measure
         GEWEI(3),     "Weight Unit
         SPART(2),     "Division
         EKGRP(3),     "Purchasing group
         VPRSV(1),     "Price control indicator
         STPRS(12),    "Standard price
         PEINH(3),     "Price unit
         SPRAS(2),     "Language key
         MAKTX(40),     "Material description
       END OF INT_MAT.
 
SELECT-OPTIONS:
            PLANT    FOR  MARC-WERKS OBLIGATORY MEMORY ID PLT,
            MATERIAL FOR  MARA-MATNR MEMORY ID MAT,
            MATLTYPE FOR  MARA-MTART MEMORY ID MTY,
            DIVISION FOR  MARA-SPART MEMORY ID DIV.
PARAMETERS:  F_FILE LIKE RLGRAP-FILENAME
             DEFAULT 'C:\DATA\ZMATERIAL.XLS' MEMORY ID F_FILE,
             GETDATA AS CHECKBOX, "Tick to download materials data to local harddisk
             UPDDATA AS CHECKBOX. "Tick to update date to Materials Master
 
IF GETDATA = 'X'.
   PERFORM DOWNLOAD_DATA.
   PERFORM DOWNLOAD_FILE.
ENDIF.
IF UPDDATA = 'X'.
   PERFORM UPLOAD_FILE.
   PERFORM UPDATE_MM.
ENDIF.
 
FORM DOWNLOAD_DATA.
SELECT * FROM MARC  WHERE LVORM EQ ' '
                      AND WERKS IN PLANT
                      AND MATNR IN MATERIAL.
    CLEAR MARA.
    SELECT SINGLE * FROM MARA WHERE MATNR =  MARC-MATNR.
    CHECK MATLTYPE.
    CHECK DIVISION.
 
    CLEAR MBEW.
    SELECT SINGLE * FROM MBEW WHERE MATNR =  MARC-MATNR
                                AND BWKEY =  MARC-WERKS.
 
    CLEAR MAKT.
    SELECT SINGLE * FROM MAKT WHERE SPRAS =  'EN'
                                AND MATNR =  MARC-MATNR.
 
    WRITE:/ MARC-WERKS,    "Plant
            MARA-MTART,    "Material type
            MARA-MATNR,    "Material number
            MARA-MATKL,    "Material group
            MARA-MBRSH,    "Industry sector
            MARA-MEINS,    "Base unit of measure
            MARA-GEWEI,    "Weight Unit
            MARA-SPART,    "Division
            MARC-EKGRP,    "Purchasing group
            MBEW-VPRSV,    "Price control indicator
            MBEW-STPRS,    "Standard price
            MBEW-PEINH,    "Price unit
            MAKT-SPRAS,    "Language key
            MAKT-MAKTX.    "Material description
 
            INT_MAT-WERKS = MARC-WERKS.    "Plant
            INT_MAT-MTART = MARA-MTART.    "Material type
            INT_MAT-MATNR = MARA-MATNR.    "Material number
            INT_MAT-MATKL = MARA-MATKL.    "Material group
            INT_MAT-MBRSH = MARA-MBRSH.    "Industry sector
            INT_MAT-MEINS = MARA-MEINS.    "Base unit of measure
            INT_MAT-GEWEI = MARA-GEWEI.    "Weight Unit
            INT_MAT-SPART = MARA-SPART.    "Division
            INT_MAT-EKGRP = MARC-EKGRP.    "Purchasing group
            INT_MAT-VPRSV = MBEW-VPRSV.    "Price control indicator
            INT_MAT-STPRS = MBEW-STPRS.    "Standard price
            INT_MAT-PEINH = MBEW-PEINH.    "Price unit
            INT_MAT-SPRAS = MAKT-SPRAS.    "Language key
            INT_MAT-MAKTX = MAKT-MAKTX.    "Material description
 
            APPEND INT_MAT.
            CLEAR  INT_MAT.
ENDSELECT.
ENDFORM.
 
FORM DOWNLOAD_FILE.
call function 'WS_DOWNLOAD'
  EXPORTING
    FILENAME                      = F_FILE
    FILETYPE                      = 'DAT'
*   FILETYPE                      = 'WK1'
  tables
    data_tab                      = INT_MAT
  EXCEPTIONS
    FILE_OPEN_ERROR               = 1
    FILE_WRITE_ERROR              = 2
    INVALID_FILESIZE              = 3
    INVALID_TYPE                  = 4
    NO_BATCH                      = 5
    UNKNOWN_ERROR                 = 6
    INVALID_TABLE_WIDTH           = 7
    GUI_REFUSE_FILETRANSFER       = 8
    CUSTOMER_ERROR                = 9
    OTHERS                        = 10.
 
IF SY-SUBRC = 0.
   FORMAT COLOR COL_GROUP.
   WRITE:/ 'Data Download Successfully to your local harddisk'.
   SKIP.
ENDIF.
ENDFORM.
 
FORM UPLOAD_FILE.
call function 'WS_UPLOAD'
  EXPORTING
    FILENAME                      = F_FILE
    FILETYPE                      = 'DAT'
*   FILETYPE                      = 'WK1'
  tables
    data_tab                      = INT_MAT
  EXCEPTIONS
    FILE_OPEN_ERROR               = 1
    FILE_WRITE_ERROR              = 2
    INVALID_FILESIZE              = 3
    INVALID_TYPE                  = 4
    NO_BATCH                      = 5
    UNKNOWN_ERROR                 = 6
    INVALID_TABLE_WIDTH           = 7
    GUI_REFUSE_FILETRANSFER       = 8
    CUSTOMER_ERROR                = 9
    OTHERS                        = 10.
 
IF SY-SUBRC = 0.
   FORMAT COLOR COL_GROUP.
   WRITE:/ 'Data Upload Successfully from your local harddisk'.
   SKIP.
ENDIF.
ENDFORM.
 
FORM UPDATE_MM.
LOOP AT INT_MAT.
* Header
    BAPI_HEAD-MATERIAL        = INT_MAT-MATNR.
    BAPI_HEAD-IND_SECTOR      = INT_MAT-MBRSH.
    BAPI_HEAD-MATL_TYPE       = INT_MAT-MTART.
    BAPI_HEAD-BASIC_VIEW      = 'X'.
    BAPI_HEAD-PURCHASE_VIEW   = 'X'.
    BAPI_HEAD-ACCOUNT_VIEW    = 'X'.
* Material Description
    REFRESH INT_MAKT.
    INT_MAKT-LANGU           = INT_MAT-SPRAS.
    INT_MAKT-MATL_DESC       = INT_MAT-MAKTX.
    APPEND INT_MAKT.
* Client Data - Basic
    BAPI_MARA1-MATL_GROUP     = INT_MAT-MATKL.
    BAPI_MARA1-BASE_UOM       = INT_MAT-MEINS.
    BAPI_MARA1-UNIT_OF_WT     = INT_MAT-GEWEI.
    BAPI_MARA1-DIVISION       = INT_MAT-SPART.
 
    BAPI_MARAX-MATL_GROUP = 'X'.
    BAPI_MARAX-BASE_UOM   = 'X'.
    BAPI_MARAX-UNIT_OF_WT = 'X'.
    BAPI_MARAX-DIVISION   = 'X'.
* Plant - Purchasing
    BAPI_MARC1-PLANT      = INT_MAT-WERKS.
    BAPI_MARC1-PUR_GROUP  = INT_MAT-EKGRP.
 
    BAPI_MARCX-PLANT      = INT_MAT-WERKS.
    BAPI_MARCX-PUR_GROUP  = 'X'.
* Accounting
    BAPI_MBEW1-VAL_AREA   = INT_MAT-WERKS.
    BAPI_MBEW1-PRICE_CTRL = INT_MAT-VPRSV.
    BAPI_MBEW1-STD_PRICE  = INT_MAT-STPRS.
    BAPI_MBEW1-PRICE_UNIT = INT_MAT-PEINH.
 
    BAPI_MBEWX-VAL_AREA   = INT_MAT-WERKS.
    BAPI_MBEWX-PRICE_CTRL = 'X'.
    BAPI_MBEWX-STD_PRICE  = 'X'.
    BAPI_MBEWX-PRICE_UNIT = 'X'.
 
    WRITE:/ BAPI_HEAD, BAPI_MARC1.
 
    call function 'BAPI_MATERIAL_SAVEDATA'
      exporting
        HEADDATA                   = BAPI_HEAD
        CLIENTDATA                 = BAPI_MARA1
        CLIENTDATAX                = BAPI_MARAX
        PLANTDATA                  = BAPI_MARC1
        PLANTDATAX                 = BAPI_MARCX
*       FORECASTPARAMETERS         =
*       FORECASTPARAMETERSX        =
*       PLANNINGDATA               =
*       PLANNINGDATAX              =
*       STORAGELOCATIONDATA        =
*       STORAGELOCATIONDATAX       =
        VALUATIONDATA              = BAPI_MBEW1
        VALUATIONDATAX             = BAPI_MBEWX
*       WAREHOUSENUMBERDATA        =
*       WAREHOUSENUMBERDATAX       =
*       SALESDATA                  = BAPI_MVKE1
*       SALESDATAX                 = BAPI_MVKEX
*       STORAGETYPEDATA            =
*       STORAGETYPEDATAX           =
      IMPORTING
        RETURN                     = BAPI_RETURN
      TABLES
        MATERIALDESCRIPTION        = INT_MAKT
*       UNITSOFMEASURE             =
*       UNITSOFMEASUREX            =
*       INTERNATIONALARTNOS        =
*       MATERIALLONGTEXT           =
*       TAXCLASSIFICATIONS         =
*       RETURNMESSAGES             =
*       PRTDATA                    =
*       PRTDATAX                   =
*       EXTENSIONIN                =
*       EXTENSIONINX               =
          .
 
IF BAPI_RETURN-TYPE = 'E'.
   WRITE:/ 'Error Message ', BAPI_RETURN.
ENDIF.
 
ENDLOOP.
ENDFORM.
*---End of Program

via http://www.sap-img.com/abap/bapi-to-copy-materials-from-one-plant-to-another.htm