SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Batch Master Creation Through BAPI_BATCH_CREATE



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sat Oct 06, 2007 11:17 pm    Post subject: Batch Master Creation Through BAPI_BATCH_CREATE Reply with quote

Code:
report ZBDCMM001 no standard page heading line-size 255.

tables: t100.



data: begin of it_data occurs 0,
matnr like mara-matnr, "matreial
charg like mcha-charg, "batch
werks like mcha-werks, "plant
lgort like vekp-lgort, "storage location
bwtar like mcha-bwtar, "valution type
zaedt(," like mcha-zaedt, "expiry date
end of it_data.

data: begin of rettab occurs 0.
include structure bapiret2.
data: end of rettab.

data: begin of numtab occurs 0.
include structure bapi1003_alloc_values_num.
data: end of numtab.
* holds data for charcateristics with type CHAR/DATE
data: begin of chatab occurs 0.
include structure bapi1003_alloc_values_char.
data: end of chatab.
* holds data for charcateristics with type CURR
data: begin of curtab occurs 0.
include structure bapi1003_alloc_values_curr.
data: end of curtab.

data: begin of it_object occurs 0.
include structure bapi1003_object_keys.
data: end of it_object.

data: return type table of bapiret2.
data: attrib type bapibatchatt.
data: w_object like bapi1003_key-object.


perform upload_data.
perform create_batch.


*------------------------Form Create_Batch------------------------

form create_batch.

loop at it_data.

attrib-EXPIRYDATE = it_data-zaedt.
attrib-VAL_TYPE = it_data-bwtar.



CALL FUNCTION 'BAPI_BATCH_CREATE'
EXPORTING
material = it_data-matnr
batch = it_data-charg
plant = it_data-werks
batchstoragelocation = it_data-lgort
BATCHATTRIBUTES = attrib
tables
return = return.

*---------------Call function for commit the transaction--------------------

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

*--------------- build the object key---------------------------------------
CLEAR: it_object, rettab.
REFRESH: it_object, rettab.

it_object-key_field = 'MATNR'.
it_object-value_int = it_data-matnr.
APPEND it_object.

it_object-key_field = 'WERKS'.
it_object-value_int = it_data-werks.
APPEND it_object.

it_object-key_field = 'CHARG'.
it_object-value_int = it_data-charg.
APPEND it_object.

CALL FUNCTION 'BAPI_OBJCL_CONCATENATEKEY'
EXPORTING
objecttable = 'MCH1'
IMPORTING
objectkey_conc = w_object
TABLES
objectkeytable = it_object
return = rettab.

*---------------End of Building object key----------------------------------


*---------------Creation of Batch Classification characterstics data--------
clear chatab.
refresh chatab.

chatab-charact = 'SLED'.
chatab-value_neutral = it_data-zaedt.
append chatab.

CALL FUNCTION 'BAPI_OBJCL_CREATE'
EXPORTING
objectkeynew = w_object
objecttablenew = 'MCH1'
classnumnew = 'SAPHAD_BATCHCLASS'
classtypenew = '023'
TABLES
ALLOCVALUESNUM = numtab
ALLOCVALUESCHAR = chatab
ALLOCVALUESCURR = curtab
return = rettab.

*---------------End of Batch Classification characterstics data--------


*---------------Call function for commit the transaction--------------------

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.


endloop.
ENDFORM.

.

form upload_data.

call function 'WS_UPLOAD'
EXPORTING
* CODEPAGE = ' '
FILENAME = 'C:\tst.txt'
FILETYPE = 'DAT'

TABLES
DATA_TAB = it_data
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.
ENDIF.
endform.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.