08-15-2008 7:33 PM
Dear All,
I have a critical problem, that my sales order is not get updated using BAPI. I need to update Bill to Party of my order. Pls see my code snippets.
LOOP AT t_zcotab INTO wa_zcotab.
CLEAR: i_hdr_inx, wa_itm_in, wa_itm_inx.
REFRESH: t_itm_in, t_itm_inx, t_return, t_hdr_inx, t_bapisdh1.
i_hdr_inx-updateflag = 'U'.
i_hdr_inx-sales_org = 'X'.
i_hdr_inx-distr_chan = 'X'.
i_hdr_inx-division = 'X'.
i_hdr_inx-purch_no_c = 'X'.
i_hdr_inx-cust_group = 'X'.
wa_itm_in-itm_number = wa_zcotab-posnr.
wa_itm_in-partn_role = 'RE'.
wa_itm_in-partn_numb = wa_zcotab-kunnr.
APPEND wa_itm_in TO t_itm_in.
wa_itm_inx-document = wa_zcotab-calloff_ord.
wa_itm_inx-itm_number = wa_zcotab-posnr.
wa_itm_inx-updateflag = 'U'.
wa_itm_inx-partn_role = 'RE'.
wa_itm_inx-p_numb_new = wa_zcotab-kunnr.
APPEND wa_itm_inx TO t_itm_inx.
CLEAR wa_sohead.
READ TABLE t_sohead INTO wa_sohead
WITH KEY vbeln = wa_zcotab-calloff_ord.
IF sy-subrc = 0.
wa_bapisdh1-sales_org = wa_sohead-vkorg.
wa_bapisdh1-distr_chan = wa_sohead-vtweg.
wa_bapisdh1-division = wa_sohead-spart.
wa_bapisdh1-purch_no_c = wa_sohead-bstnk.
ENDIF.
"----
"Update Bill to on ZCO item from ZMO item
"----
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = wa_zcotab-calloff_ord
order_header_in = wa_bapisdh1
order_header_inx = i_hdr_inx
TABLES
return = t_return
partners = t_itm_in
partnerchanges = t_itm_inx.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDLOOP.
ENDIF.
ENDIF.
<REMOVED BY MODERATOR>
Thanks,
Senthil Kumar L
Edited by: Alvaro Tejada Galindo on Aug 15, 2008 3:23 PM
08-15-2008 9:29 PM
It looks, you are passing values instead of the FLAG ( X or Space) in the table T_ITM_INX .
It should be Like:
wa_itm_inx-itm_number = wa_zcotab-posnr.
wa_itm_inx-updateflag = 'U'.
wa_itm_inx-partn_role = 'X'.
wa_itm_inx-p_numb_new = 'X'.
APPEND wa_itm_inx TO t_itm_inx.
Regards,
Naimesh Patel
08-15-2008 7:51 PM
are you getting any error. what is the return message you are getting.
Regards
Vijay
08-15-2008 8:24 PM
Vijay,
I get this error. It goes to the standard code an i see vbak-vbeln is initial and i dont know why.
E |V1 |045 |Enter the document number
Main program SAPMV45A
Source code of MV45AF0B_BELEG_LESEN 2
da_bapi type c.
local: r185d-dataloss.
Damit beim Kopieren die offene Referenzmenge stimmt:
perform dummy(sapfv45c).
perform programm_laden(sapfv45p).
bl_error = charx.
if vbak-vbeln is initial.
message e045.
endif.
Beleg initialisieren, falls erforderlich
if vbak-vbtyp ne space.
da_vbeln = vbak-vbeln.
08-15-2008 8:30 PM
CLEAR wa_sohead.
READ TABLE t_sohead INTO wa_sohead
WITH KEY vbeln = wa_zcotab-calloff_ord.
IF sy-subrc = 0. "<---------------May be this read failing
wa_bapisdh1-sales_org = wa_sohead-vkorg.
wa_bapisdh1-distr_chan = wa_sohead-vtweg.
wa_bapisdh1-division = wa_sohead-spart.
wa_bapisdh1-purch_no_c = wa_sohead-bstnk.
ENDIF.
check it once in debugging mode.
08-15-2008 9:10 PM
Vijay,
What you said is right. That Read Stmt Fails, But I have hard coded these values in the debugg mode, Still getting the same error message.
wa_bapisdh1-sales_org = '2004'.
wa_bapisdh1-distr_chan = '10'.
wa_bapisdh1-division = '60'.
wa_bapisdh1-purch_no_c = 'test bill to 1'.
Data hard coded in the debugger because need to transport it for data. Please help
Read Stmt fails because i used wrong internal table name t_sohead instead of t_sohead1.
Edited by: senthil kumar on Aug 16, 2008 1:43 AM
08-15-2008 9:29 PM
It looks, you are passing values instead of the FLAG ( X or Space) in the table T_ITM_INX .
It should be Like:
wa_itm_inx-itm_number = wa_zcotab-posnr.
wa_itm_inx-updateflag = 'U'.
wa_itm_inx-partn_role = 'X'.
wa_itm_inx-p_numb_new = 'X'.
APPEND wa_itm_inx TO t_itm_inx.
Regards,
Naimesh Patel
08-15-2008 9:44 PM
I am passing the t_itm_inx to partnerchanges of the BAPI_SALESORDER_CHANGE, the structure of the partnerchanges is BAPIPARNRC. The Field length for PARTN_ROLE, P_NUMB_NEW is more than CHAR 1.
partnerchanges = t_itm_inx.
Do i have to pass X in PARTN_ROLE & P_NUMB_NEW .
Thanks,
Senthil
08-15-2008 10:12 PM
Hi,
Populated flag as suggested, Still same error. Where i am going wrong?
wa_itm_inx-itm_number = wa_zcotab-posnr.
wa_itm_inx-updateflag = 'U'.
wa_itm_inx-partn_role = 'X'.
wa_itm_inx-p_numb_new = 'X'.
APPEND wa_itm_inx TO t_itm_inx.
Thanks,
Senthil
08-16-2008 4:08 AM
>P_NUMB_NEW is more than CHAR 1.
>partnerchanges = t_itm_inx.
>Do i have to pass X in PARTN_ROLE & P_NUMB_NEW .
no you should not pass any X here...
fill this partner changes table and pass directly.
DOCUMENT <----order number
ITM_NUMBER <------item
UPDATEFLAG <-----U
PARTN_ROLE <----RE
P_NUMB_OLD <----old partner number
P_NUMB_NEW <-----new partner number
08-19-2008 4:56 PM
Hi Vijay & All,
The Scenario is to Copy ZMO (Manufacturing order VA42) to ZCO (Call Off Order VA02), This is done thro BDC. Here the Bill to Party number is updated incorrectly from ZMO to ZCO ( It copies from Header) . Now the requirnment is, once the order is created, need to update the correct item bill to using BAPI at the end of the program (same program where the BDC is used to create the order). BAPI Used as suggested above and end up with error in return table "Enter the document number".
Scenario 1: Copy all Items of ZMO to ZCO
Main program SAPLV45A
Source code of LV45AU06
I had a Break-point in the below line.
VBAK-VBELN = DOCUMENT_NUMBER.
PERFORM BELEG_LESEN(SAPMV45A).
PERFORM KONV_SELECT(SAPFV45P).
I ran my program which has FM BAPI_SALESORDER_CHANGE, It stops in the break point. The value for the Document_Number is there, which is also moved to VBAK-VBELN. I pressed F5 in the debugger to enter into form beleg_lesen. Now VBAK-VBELN is clear and is blank and enup with a error message "Enter the document number". Did any of you has encountered this problem?? Is this the problem with my Code? Or any Functional Setting or Oss Note?
Scenario 2: Copy all Items of ZMO to ZCO other than item 10.
A maintenance view exist for this(ZCo creation can be controlled here), when i Check mark the item 10 as Hold, the item 10 will not be created for the ZCO.
This time i ran my program. Got Value in VBAK-VBELN and to my surprise the value is not cleared inside the form, ZCO has been created with item 20, 30 and 40. Bill to has been updated with the correct data.
Can someone help me where the problem lies? What is the problem with item 10 and why VBAK-VBELN is getting cleared when ZCO is created with item 10.
Thanks for your time and patience.
Thanks,
Senthil
08-19-2008 7:26 PM
wa_itm_in-document = wa_zcotab-calloff_ord. "? where is this in your code....
wa_itm_in-itm_number = wa_zcotab-posnr.
wa_itm_in-partn_role = 'RE'.
wa_itm_in-partn_numb = wa_zcotab-kunnr.
APPEND wa_itm_in TO t_itm_in.
wa_itm_inx-document = wa_zcotab-calloff_ord.
wa_itm_inx-itm_number = wa_zcotab-posnr.
wa_itm_inx-updateflag = 'U'.
wa_itm_inx-partn_role = 'RE'.
wa_itm_inx-p_numb_new = wa_zcotab-kunnr.
APPEND wa_itm_inx TO t_itm_inx.
08-19-2008 7:46 PM
Hi,
It is with the internal table structure.
TYPES : BEGIN OF x_zcotab,
vbeln TYPE zsdttcalloff-vbeln,
posnr TYPE zsdttcalloff-posnr,
calloff_ord TYPE zsdttcalloff-calloff_ord,
calloff_itm TYPE zsdttcalloff-calloff_itm,
kunnr TYPE vbpa-kunnr,
END OF x_zcotab.
DATA : t_zcotab TYPE TABLE OF x_zcotab,
wa_zcotab LIKE LINE OF t_zcotab.
Here is it gets populated
"----
" Get ZMO Bill To customer number
"----
SELECT vbeln posnr kunnr INTO
TABLE t_kunnr FROM vbpa
FOR ALL ENTRIES IN i_zsl
WHERE vbeln = i_zsl-vbeln
AND posnr = i_zsl-posnr
AND parvw = 'RE'.
IF sy-subrc = 0.
SORT t_kunnr BY vbeln posnr.
"----
" Get ZCO items created form ZMO items
"----
SELECT vbeln posnr calloff_ord calloff_itm
FROM zsdttcalloff INTO TABLE t_zcotab
FOR ALL ENTRIES IN t_kunnr
WHERE vbeln = t_kunnr-vbeln
AND posnr = t_kunnr-posnr.
LOOP AT t_zcotab INTO wa_zcotab.
......
......
wa_itm_inx-document = wa_zcotab-calloff_ord.
wa_itm_inx-itm_number = wa_zcotab-posnr.
wa_itm_inx-updateflag = 'U'.
wa_itm_inx-partn_role = 'RE'.
wa_itm_inx-p_numb_new = wa_zcotab-kunnr.
APPEND wa_itm_inx TO t_itm_inx.
........
.......
ENDLOOP.
I check in the debugger, internal table gets populated with values and also wa_zcotab-calloff_ord.
Values Copied from the debugger:
1 VBELN POSNR CALLOFF_ORD CALLOFF_ITM KUNNR
1 0040212482|000020|0003114981 |000020 |0000552200
2 0040212482|000030|0003114981 |000030 |0000552200
3 0040212482|000040|0003114981 |000040 |0000552200
08-19-2008 7:53 PM
wa_itm_in-document = wa_zcotab-calloff_ord. "? where is this in your code....
what i mean is the above line is missing in your code.
wa_itm_in-itm_number = wa_zcotab-posnr.
wa_itm_in-partn_role = 'RE'.
wa_itm_in-partn_numb = wa_zcotab-kunnr.
APPEND wa_itm_in TO t_itm_in.
wa_itm_inx-document = wa_zcotab-calloff_ord.
wa_itm_inx-itm_number = wa_zcotab-posnr.
wa_itm_inx-updateflag = 'U'.
wa_itm_inx-partn_role = 'RE'.
wa_itm_inx-p_numb_new = wa_zcotab-kunnr.
APPEND wa_itm_inx TO t_itm_inx.
08-19-2008 7:59 PM
Maybe my naming convension would have confused you.
wa_itm_in TYPE bapiparnr,
wa_itm_in doesnot have a field document.
08-19-2008 9:06 PM
OK , sorry for the confusion.
i just tested small case
The following prameters i passed to the Function
1. SALESDOCUMENT order number
2. in ORDER_HEADER_IN
SALES_ORG
DISTR_CHAN
DIVISION
in ORDER_HEADER_INX
UPDATEFLAG U
SALES_ORG X
DISTR_CHAN X
DIVISION X
3. in Partners
PARTN_ROLE RE
PARTN_NUMB 0000000003
ITM_NUMBER 000010
4. partner changes.( PARTNERCHANGES)
DOCUMENT 0000013059
ITM_NUMBER 000010
UPDATEFLAG U
PARTN_ROLE RE
P_NUMB_OLD 0000000001
P_NUMB_NEW 0000000003
i am updating the partner, check it once, only pass this information and see..
08-19-2008 9:23 PM
Okay Vijay, Did the suggested changes, Requested for transport, Keep you updated once my code reaches QAS.
Thanks,
Senthil
08-19-2008 6:37 PM