2011 Oct 24 3:56 PM
Hi guys,
I'm trying to create a return with reference to a Internal Invoice.
Here goes the code:
"Preenchimento Order Header In
CLEAR: ls_order_header_in.
ls_order_header_in-price_date = sy-datum. "Data Fix.Preço
ls_order_header_in-ref_doc = ls_zvpfpdev-vbeln_fi. "Documento Referencia
ls_order_header_in-refdoctype = 'M'. "Documento Referencia
ls_order_header_inx-ref_doc = 'X'. "Documento Referencia
ls_order_header_inx-updateflag = 'I'.
"Preenchimento da Order Partner
CLEAR: lt_order_partners, ls_order_partners.
ls_order_partners-partn_role = 'AG'. "emissor ordem
ls_order_partners-partn_numb = '0000109282'. "emissor ordem
APPEND ls_order_partners TO lt_order_partners.
CALL FUNCTION 'BAPI_CUSTOMERRETURN_CREATE'
EXPORTING
SALESDOCUMENTIN =
return_header_in = ls_order_header_in
return_header_inx = ls_order_header_inx
IMPORTING
salesdocument = zvpfpdev-vbeln_d_pi
TABLES
return = lt_return .
It is strugglin with the determination of the VKORG, VTWEG, and SPART, and on the return says he couldn't determine this for the costumer ..
Where I'm doing something wrong ?
2011 Oct 24 4:25 PM
Hi
You need to fill the following fields: BAPISDHD1-SALES_ORG, BAPISDHD1-DISTR_CHAN and BAPISDHD1-DIVISION
You can get them from KNVV table
Max
2011 Oct 24 4:25 PM
Hi
You need to fill the following fields: BAPISDHD1-SALES_ORG, BAPISDHD1-DISTR_CHAN and BAPISDHD1-DIVISION
You can get them from KNVV table
Max
2011 Oct 24 6:46 PM
Max,
Thanks for your response, but isn't it supposed to fill it automaticly when you give him a reference document ?
I know which ones they are, but i was told that is suppose to go automaticly.
Cheers,
2011 Oct 24 7:32 PM
Uhm
yes you're right, but probably you're not filling the right field:
s_order_header_in-ref_doc = ls_zvpfpdev-vbeln_fi. "Documento Referencia
ls_order_header_in-refdoctype = 'M'. "Documento Referencia
ls_order_header_inx-ref_doc = 'X'. "Documento Referencia
ls_order_header_inx-updateflag = 'I'.I think it should be filled:
REFOBJTYPE
REFOBJKEY
REFDOCTYPE
Max
2011 Oct 24 10:36 PM
Thanks for the quick reply Max.
I've tried that, but no luck. Anyway, Im doing a select to the VBRK with the document_reference to get it.
I think its correct.
Anyway, as is a return, I go to LIPS to get the materials that are being returned. I make reference and the psnr, but the CHARG ( on the BAPI is BATCH field ) is not updated.
item_counter = item_counter + 10.
ls_return_items_in-itm_number = item_counter."Posição Item em si
ls_return_items_inx-itm_number = item_counter."Posição Para Update de item
ls_return_schedules_in-itm_number = item_counter."Posição Para Preço
ls_return_schedules_inx-itm_number = item_counter."Posição Para Update do Preço
ls_return_items_in-po_itm_no = ls_zvpfpdev-posnr.
ls_return_items_inx-po_itm_no = 'X'.
ls_return_items_in-batch = ls_zvpfpdev-charg."Lote
ls_return_items_inx-batch = 'X'."Lote
ls_return_items_in-target_qty = ls_zvpfpdev-lfimg."Quantidade Valor
ls_return_items_inx-target_qty = 'X'."Quantidade Update
ls_return_items_in-rnddlv_qty = ls_zvpfpdev-lfimg."Quantidade
ls_return_items_inx-rnddlv_qty = 'X'."Quantidade
ls_return_items_in-comp_quant = ls_zvpfpdev-lfimg."Quantidade
ls_return_items_inx-comp_quant = 'X'.
ls_return_items_in-ref_doc = ls_zvpfpdev-vbeln_d_fp."Documento Referencia
ls_return_items_inx-ref_doc = 'X'."Documento Referencia
ls_return_items_in-material = ls_zvpfpdev-matnr."Material
ls_return_items_inx-material = 'X'.
2011 Oct 27 3:52 PM
Solved.
Here goes my coding.
FORM order_header_in_fill USING ls_zvpfpdev TYPE zvpfpdev CHANGING ls_order_header_in TYPE bapisdhd1 ls_order_header_inx TYPE bapisdhd1x.
ls_order_header_in-refobjtype = 'BUS2032'.
ls_order_header_in-refobjkey = ls_zvpfpdev-vbeln_fi.
ls_order_header_in-refdoctype = 'ZPI1'.
ls_order_header_in-price_date = sy-datum. "Data Fix.Preço
*
ls_order_header_in-doc_type = c_zprf."Passagem do Tipo de Documento
ls_order_header_inx-doc_type = 'X'.
*
ls_order_header_in-req_date_h = sy-datum. "MODIFICAR PARA DATA NO ECRA!!!!!!
*
ls_order_header_in-purch_no_c = ls_zvpfpdev-vbeln_d_fp. "Nº Pedido Cliente
ls_order_header_inx-purch_no_c = 'X'. "Nº Pedido Cliente
*
*
ls_order_header_in-ref_doc = ls_zvpfpdev-vbeln_fi. "Documento Referencia
SELECT SINGLE vkorg vtweg spart
FROM vbrk
INTO (ls_order_header_in-sales_org,
ls_order_header_in-distr_chan,
ls_order_header_in-division)
WHERE vbeln = ls_zvpfpdev-vbeln_fi.
ls_order_header_inx-sales_org = 'X'.
ls_order_header_inx-distr_chan = 'X'.
ls_order_header_inx-division = 'X'.
ls_order_header_in-refdoc_cat = 'M'.
ls_order_header_inx-refdoc_cat = 'X'.
ls_order_header_in-refdoctype = 'ZPI1'.
ls_order_header_inx-updateflag = 'I'.
FORM items_fill CHANGING lt_return_items_in TYPE STANDARD TABLE
lt_return_items_inx TYPE STANDARD TABLE
lt_return_schedules_in TYPE STANDARD TABLE
lt_return_schedules_inx TYPE STANDARD TABLE.
DATA: ls_return_items_in TYPE bapisditm.
DATA: ls_return_items_inx TYPE bapisditmx.
DATA: ls_return_schedules_in TYPE bapischdl.
DATA: ls_return_schedules_inx TYPE bapischdlx.
DATA: item_counter TYPE i.
CLEAR: ls_return_items_in, lt_return_items_in,
ls_return_items_inx, lt_return_items_inx,
ls_return_schedules_in, lt_return_schedules_in,
ls_return_schedules_inx, lt_return_schedules_inx,
ls_zvpfpdev,
item_counter.
LOOP AT lt_zvpfpdev INTO ls_zvpfpdev WHERE posnr < '9000'.
item_counter = item_counter + 10.
ls_return_items_in-itm_number = item_counter."Posição Item em si
ls_return_items_inx-itm_number = item_counter."Posição Para Update de item
ls_return_schedules_in-itm_number = item_counter."Posição Para Preço
ls_return_schedules_inx-itm_number = item_counter."Posição Para Update do Preço
ls_return_items_in-material = ls_zvpfpdev-matnr."Material
ls_return_items_inx-material = 'X'.
"Vai buscar Centro
SELECT werks UP TO 1 ROWS
FROM vbrp
INTO ls_return_items_in-plant
WHERE vbeln = ls_zvpfpdev-vbeln_fi.
ENDSELECT.
ls_return_items_inx-plant = 'X'.
"Lote não necessario
ls_return_items_in-batch = ls_zvpfpdev-charg."Lote
ls_return_items_inx-batch = 'X'."Lote
ls_return_items_in-target_qty = ls_zvpfpdev-lfimg."Quantidade Valor
ls_return_items_inx-target_qty = 'X'."Quantidade Update
ls_return_items_in-rnddlv_qty = ls_zvpfpdev-lfimg."Quantidade
ls_return_items_inx-rnddlv_qty = 'X'."Quantidade
ls_return_items_in-comp_quant = ls_zvpfpdev-lfimg."Quantidade
ls_return_items_inx-comp_quant = 'X'.
ls_return_items_in-ref_doc = ls_zvpfpdev-vbeln_d_fp."Documento Referencia
ls_return_items_inx-ref_doc = 'X'."Documento Referencia
ls_return_items_in-po_itm_no = ls_zvpfpdev-posnr."Posição no documento de referencia
ls_return_items_inx-po_itm_no = 'X'.
"Determinação De Centro de Lucro Conforme Factura Interna
SELECT SINGLE prctr FROM vbrp
INTO ls_return_items_in-profit_ctr
WHERE vbeln = ls_zvpfpdev-vbeln_fi
AND matnr = ls_zvpfpdev-matnr.
ls_return_items_inx-profit_ctr = 'X'.
"Preenchimento de Valores de quantidade
ls_return_schedules_in-req_qty = ls_zvpfpdev-lfimg.
ls_return_schedules_inx-req_qty = 'X'.
APPEND ls_return_items_in TO lt_return_items_in.
CLEAR: ls_return_items_in.
APPEND ls_return_items_inx TO lt_return_items_inx.
CLEAR: ls_return_items_inx.
APPEND ls_return_schedules_in TO lt_return_schedules_in.
CLEAR ls_return_schedules_in.
APPEND ls_return_schedules_inx TO lt_return_schedules_inx.
CLEAR ls_return_schedules_inx.
ENDLOOP.
ENDFORM.
"Preenchimento da Order Partner
CLEAR: lt_order_partners, ls_order_partners.
ls_order_partners-partn_role = 'AG'. "emissor ordem (kunnr) = 109282
ls_order_partners-partn_numb = '0000109282'. "emissor ordem (kunnr) = 109282
APPEND ls_order_partners TO lt_order_partners.
CALL FUNCTION 'BAPI_CUSTOMERRETURN_CREATE'
EXPORTING
return_header_in = ls_order_header_in
return_header_inx = ls_order_header_inx
SENDER =
BINARY_RELATIONSHIPTYPE =
INT_NUMBER_ASSIGNMENT =
BEHAVE_WHEN_ERROR =
LOGIC_SWITCH =
testrun = ''
CONVERT = ' '
IMPORTING
salesdocument = l_vbeln
TABLES
return = lt_return
return_items_in = lt_return_items_in
return_items_inx = lt_return_items_inx
return_partners = lt_order_partners
return_schedules_in = lt_return_schedules_in
return_schedules_inx = lt_return_schedules_inx
RETURN_CONDITIONS_IN =
RETURN_CFGS_REF =
RETURN_CFGS_INST =
RETURN_CFGS_PART_OF =
RETURN_CFGS_VALUE =
RETURN_CFGS_BLOB =
RETURN_CFGS_VK =
RETURN_CFGS_REFINST =
RETURN_TEXT =
RETURN_KEYS =
EXTENSIONIN =
PARTNERADDRESSES =
.
"Commit da VA01
DATA: l_return_comit TYPE bapiret2.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
return = l_return_comit.
Works perfectly.
Thanks for the help !