‎2009 Feb 16 3:54 PM
Dear SAP gurus
I am trying to test run the BAPI BAPI_QUOTATION_CREATEFROMDATA2, using the sample data that came with IDES version of ECC 6.0.
When I manually try to test run by going to SE37, selecting the bapi
'BAPI_QUOTATION_CREATEFROMDATA2' and then clicking on Test/Execute(F8) button.
I entered the minimum data required for quotation header in, quotation header inx, quotation_items_in and quotaion_schedules_in.
However, when i try to run it says that : 'The sales document is not yet complete'
I realized that I haven't entered ship-to-party and sold-to-party. Where can i enter these two values and what are the called (the abriviations make it difficult to find where to enter these two values).
Your help will be greatly appreciated.
Thanks
Ram
‎2009 Feb 16 4:40 PM
Ram,
I guess you forgot to fill the quotation_partners structure.
See, in the code above, the structures that I filled in a program.
CALL FUNCTION 'BAPI_QUOTATION_CREATEFROMDATA2'
EXPORTING
quotation_header_in = t_head_create
IMPORTING
salesdocument = v_vbeln
TABLES
return = t_retorno_create
quotation_items_in = t_items_create
quotation_partners = t_partner_create
quotation_schedules_in = items_sched.
good lucky.
‎2009 Feb 16 5:35 PM
Hi Douglas
Thanks for your response.
Infact I have entered all the info that you have suggested in your code, but looks like I am not filling them completely. I am trying to do it not by calling the BAPI the way you are trying to do, but to call it as a test run by opening the BAPI itself and pressing 'F8'.
When I press F8 it gives me a scree where I can selectively enter the data but when I open each item, it showes a huge table with many many fields (names of these fields are abreviated and hard to make out which is which). I have figured out that i haven't entered 'ship-to-party' and 'sold-to-party'. I don't know what these fields are called.
‎2009 Feb 16 5:45 PM
Hello Douglas,
One more request.
Will it be possible to copy and paste the structure of the following so that I will know what kind of data you have entered.
t_head_create
v_vbeln
t_retorno_create
t_items_create
t_partner_create
Thanks
Ram
‎2009 Feb 19 12:19 PM
Ram,
Sorry for the late reply, I will pass you the source. In fact I was using the code like a RFC.
Try to adapt to your business area.
Remember to fill the X´s structures as the following source
{{
FUNCTION ywsd003.
.
.
.
Tabulação de dados
head-doc_type = 'YRES'.
head-sales_org = '0050'.
head-distr_chan = '11'.
head-division = '10'.
items_sched-itm_number = 0.
IF salesdocument IS INITIAL.
LOOP AT items.
Segundo item como item 20 - prever placa.
IF sy-tabix EQ 2.
items_sched-itm_number = 20.
ENDIF.
ADD 10 TO items_sched-itm_number.
MOVE items_sched-itm_number TO items-itm_number.
MODIFY items INDEX sy-tabix.
IF items-target_qty IS INITIAL.
SELECT SINGLE mtart
FROM mara
INTO v_mtart
WHERE matnr EQ items-material.
IF sy-subrc EQ 0 AND v_mtart EQ 'ZSER'.
items_sched-req_qty = data_fim - data_inicio.
call function 'YYPCL_MV45AFZZ_EXIT_HE'
EXPORTING
pi_auart = head-doc_type
pi_data_ini = data_inicio
pi_hora_ini = hora_inicio
pi_data_fim = data_fim
pi_hora_fim = hora_fim
IMPORTING
pe_diarias = v_kwmeng.
v_n = v_kwmeng.
items_sched-req_qty = v_n.
ELSE.
MOVE 1 TO items_sched-req_qty.
ENDIF.
ELSE.
MOVE items-target_qty TO items_sched-req_qty.
ENDIF.
APPEND items_sched.
ENDLOOP.
ELSE.
v_vbeln = salesdocument.
UNPACK v_vbeln TO v_vbeln.
bape_vbak-vbeln = v_vbeln.
ENDIF.
*Campos Adicionais
bape_vbak-zzdtprev = data_inicio.
bape_vbak-zzhrprev = hora_inicio.
bape_vbak-zzdtefet = data_fim.
bape_vbak-zzhrefet = hora_fim.
Completa número da ordem com zeros a direita.
extensionin-structure = 'BAPE_VBAK'.
extensionin-valuepart1 = bape_vbak.
APPEND extensionin.
CLEAR extensionin.
IF NOT bape_vbak-zzdtvalid IS INITIAL.
v_bape_vbakx-zzdtvalid = 'X'.
ENDIF.
IF NOT bape_vbak-zzhrvalid IS INITIAL.
v_bape_vbakx-zzhrvalid = 'X'.
ENDIF.
IF NOT bape_vbak-zzendereco IS INITIAL.
v_bape_vbakx-zzendereco = 'X'.
ENDIF.
*ZZDTPREV
IF NOT bape_vbak-zzdtprev IS INITIAL.
v_bape_vbakx-zzdtprev = 'X'.
ENDIF.
*ZZHRPREV
IF NOT bape_vbak-zzhrprev IS INITIAL.
v_bape_vbakx-zzhrprev = 'X'.
ENDIF.
*ZZDTEFET
IF NOT bape_vbak-zzdtefet IS INITIAL.
v_bape_vbakx-zzdtefet = 'X'.
ENDIF.
*ZZHREFET
IF NOT bape_vbak-zzhrefet IS INITIAL.
v_bape_vbakx-zzhrefet = 'X'.
ENDIF.
extensionin-structure = 'BAPE_VBAKX'.
extensionin-valuepart1 = v_bape_vbakx.
APPEND extensionin.
CLEAR extensionin.
conditions-itm_number = 10.
conditions-cond_type = v_condicao.
conditions-cond_value = desconto.
APPEND conditions.
MNR001 - ANDRE - 11/12/07 ----- inclusao do desconto geral -- comentado em 11.01.08 (p/produção)
descomentado em 28.01.08 (QA)
conditions-itm_number = 00.
conditions-cond_type = 'ZDNE'.
conditions-cond_value = ( descgeral / 10 ) .
APPEND conditions.
CASE salesdocument.
WHEN ' '.
CLEAR v_vbeln.
CALL FUNCTION 'BAPI_QUOTATION_CREATEFROMDATA2'
EXPORTING
quotation_header_in = head
IMPORTING
salesdocument = v_vbeln
TABLES
return = return
quotation_items_in = items
quotation_items_inx = itemsx
quotation_schedules_in = items_sched
quotation_conditions_in = conditions
quotation_conditions_inx = conditionsx
quotation_partners = partner
quotation_text = texts
extensionin = extensionin.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
DELETE return WHERE id = 'V4' AND number = 219.
CLEAR return.
Se foi criada a reserva
IF NOT v_vbeln IS INITIAL.
retorno-type = return-type.
retorno-message = return-message.
ENDIF.
APPEND retorno.
WHEN OTHERS.
ENDCASE.
ENDFUNCTION.
}}
Good Lucky.
‎2009 Feb 19 1:59 PM
Thanks a lot Douglas. I really appreciate it.
I will try and let you know how it goes.
Ram
‎2009 Feb 19 2:12 PM
Okay...
If you need the complete source tell me and I email you...
‎2009 Feb 24 3:02 AM
thanks to everyone for the response.
By selecting
BAPI_TRASACTION_COMMITT in the test sequence, the quote got saved.