‎2007 Aug 06 7:51 AM
Hi,
I am in between of a requirement of updating Sales Order via TR-VA02.
The changes required are uploading of MATERIAL CHARACTERISTICS - Material
Number Wise / POSNR wise.
I am using BAPI - BAPI_SALESORDER_CHANGE
to do the same. I am getting a success message, but the charateristics
are not getting uploaded.
I am pasting the code for the same.
&----
*& Report ZZM_OTDM_SD_CHAR_BAPI_TEMP *
*& *
&----
*& *
*& *
&----
report ZZM_OTDM_SD_CHAR_BAPI_TEMP .
*
types : begin of T_TAB,
OLD_SAL_ORD(12) type C,
METERIAL_NUM type MATNR,
posnr type POSNR_VA,
CHAR_NAME(30) type C,
CHAR_VALUE(30) type C,
VBELN(10) type C,
end of T_TAB,
begin of T_TAB1,
VBELN(10) type C,
METERIAL_NUM type MATNR,
posnr type POSNR_VA,
CHAR_NAME(30) type C,
CHAR_VALUE(30) type C,
end of T_TAB1,
begin of T_CON_TAB,
VBELN type VBELN, " Sales Document Number
IHREZ_E type IHREZ_E,
end of T_CON_TAB.
*
data: IT_CHAR_TAB type standard table of BAPICUVAL,
IT_RETURN type standard table of BAPIRET2,
IT_TAB type standard table of T_TAB,
IT_TAB1 type standard table of T_TAB1,
IT_CON_TAB type standard table of T_CON_TAB,
IT_ORDER_ITEM type standard table of BAPISDITM,
IT_ORDER_ITEM_INX type standard table of BAPISDITMX.
data: WA_HEADER_INX type BAPISDH1X,
WA_ORDER_HEADER_IN type BAPISDH1,
WA_TAB type T_TAB,
WA_TAB1 type T_TAB1,
WA_CON_TAB type T_CON_TAB,
WA_CHAR_TAB type BAPICUVAL,
WA_ORDER_ITEM type BAPISDITM,
WA_ORDER_ITEM_INX type BAPISDITMX.
data: LV_VBELN like BAPIVBELN-VBELN,
V_FILE type STRING,
LV_REF_NUM(10) type C.
data: FILE_UPLOAD type STRING.
*
----
SELECT-OPTIONS / PARAMETERS *
----
*--- Input files
selection-screen begin of block A with frame title TEXT-020.
parameters: P_FILE like RLGRAP-FILENAME.
selection-screen end of block A.
FILE_UPLOAD = P_FILE.
*----get flat file data
perform GET_DATA.
----
AT SELECTION SCREEN EVENT. *
----
at selection-screen on value-request for P_FILE.
*---get the file name
perform GET_FILE.
*
start-of-selection.
perform FETCH_DATA.
*
loop at IT_TAB1 into WA_TAB1.
lv_ref_num = wa_tab1-vbeln.
LV_VBELN = WA_TAB1-VBELN.
WA_HEADER_INX-UPDATEFLAG = 'U'.
WA_CHAR_TAB-CHARC = WA_TAB1-CHAR_NAME.
WA_CHAR_TAB-VALUE = WA_TAB1-CHAR_VALUE.
append WA_CHAR_TAB to IT_CHAR_TAB.
WA_ORDER_ITEM-ITM_NUMBER = WA_TAB1-posnr.
WA_ORDER_ITEM_INX-ITM_NUMBER = WA_TAB1-posnr.
WA_ORDER_ITEM_INX-UPDATEFLAG = 'U'.
append WA_ORDER_ITEM to IT_ORDER_ITEM.
append WA_ORDER_ITEM_INX to IT_ORDER_ITEM_INX.
at end of VBELN.
Call function sales order change for populating
the characterstic values
call function 'BAPI_SALESORDER_CHANGE'
exporting
SALESDOCUMENT = LV_VBELN
ORDER_HEADER_IN = WA_ORDER_HEADER_IN
ORDER_HEADER_INX = WA_HEADER_INX
tables
RETURN = IT_RETURN
ORDER_ITEM_IN = IT_ORDER_ITEM
ORDER_ITEM_INX = IT_ORDER_ITEM_INX
ORDER_CFGS_VALUE = IT_CHAR_TAB.
call function 'BAPI_TRANSACTION_COMMIT'.
refresh :IT_CHAR_TAB,
IT_ORDER_ITEM_INX,
IT_ORDER_ITEM.
endat.
clear: LV_VBELN,
WA_TAB1,
WA_CHAR_TAB,
WA_HEADER_INX,
WA_ORDER_ITEM,
WA_ORDER_ITEM_INX.
endloop.
*
&----
*& Form GET_DATA
&----
text
----
--> p1 text
<-- p2 text
----
form GET_DATA .
*
call function 'GUI_UPLOAD'
exporting
FILENAME = FILE_UPLOAD
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
tables
DATA_TAB = IT_TAB.
*
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 GET_FILE
&----
text
----
--> p1 text
<-- p2 text
----
form GET_FILE .
*
call function 'F4_FILENAME'
exporting
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
importing
FILE_NAME = P_FILE.
*
endform. " GET_FILE
&----
*& Form fetch_data
&----
text
----
--> p1 text
<-- p2 text
----
form FETCH_DATA .
data : LV_CHAR_NAME(30) type C.
if IT_TAB is not initial.
select VBELN
IHREZ_E
from VBKD
into table IT_CON_TAB
for all entries in IT_TAB
where IHREZ_E eq IT_TAB-OLD_SAL_ORD.
endif.
*
loop at IT_TAB into WA_TAB.
read table IT_CON_TAB into WA_CON_TAB
with key IHREZ_E = WA_TAB-OLD_SAL_ORD.
if SY-SUBRC eq 0.
concatenate 'IN' WA_TAB-CHAR_NAME into LV_CHAR_NAME.
WA_TAB-VBELN = WA_CON_TAB-VBELN.
WA_TAB-CHAR_NAME = LV_CHAR_NAME.
WA_TAB1-VBELN = WA_CON_TAB-VBELN.
WA_TAB1-posnr = WA_TAB-posnr.
WA_TAB1-CHAR_NAME = LV_CHAR_NAME.
WA_TAB1-CHAR_VALUE = WA_TAB-CHAR_VALUE.
append WA_TAB1 to IT_TAB1.
clear WA_TAB1.
modify IT_TAB from WA_TAB transporting CHAR_NAME VBELN.
endif.
clear :LV_CHAR_NAME,
WA_CON_TAB,
WA_TAB.
endloop.
endform. " fetch_data
-
Structure of flat file:
5111000342 000100 Min. required 9.000000 m3/h
5111000342 000100 Bypass required 9.000000 l/s
5111000342 000100 Allow. dischrg pressure (t/o) 9.000000 bar
where :
5111000342 = sales order number
000100 = posnr
Min. required = charateristics name
9.000000 m3/h = characteristics value.
Thanks in anticipation
Jitendra Gujrathi
‎2007 Aug 06 8:01 AM
Hi,
As per this BAPI
It will
Only specified fields that should be changed.
if u want to change the Characteristics pass the Characteristic paramaters in IT_ORDER_ITEM - table.
regards,
Nandha
Reward if it helps