‎2007 Jun 03 5:00 PM
Hi!
what are the basic parametres to send to RV_DELIVERY_CREATE?
I mean is it a mandatory issue to send Tables LVBAK, LVBAP, LVBEP and all others? And how to check if Delivery was created succesfully?
Maybe someone has a sample of using this FM?
Will reward points.
BR, M.
‎2007 Jun 03 5:32 PM
I did not have code for RV_DELIVERY_CREATE ,i have program with SHP_VL10_DELIVERY_CREATE_PARA This function module
----
Table declaration *
----
tables: vbfa,
zwvbak_curr.
----
Selection Screen *
----
selection-screen begin of block b01 with frame title text-b01.
parameters: p_dwerk like zfdwstatus-werks default '1000' obligatory,
p_vdatu like zfdwstatus-vdatu obligatory.
selection-screen end of block b01.
selection-screen begin of block b02 with frame title text-b02.
select-options: s_vbeln for zwvbak_curr-vbeln.
selection-screen end of block b02.
----
Data definition *
----
data: d_task(5) type n.
data: d_vbeln like vbak-vbeln,
d_loop type i,
d_zzrun like zfdwstatus-zzrun.
data: t_vbak like vbak occurs 0 with header line.
data: t_vbap like vbapvb occurs 0 with header line.
data: t_vbep like vbepvb occurs 0 with header line.
data: t_vbkd like vbkdvb occurs 0 with header line.
data: t_vbpa like vbpavb occurs 0 with header line.
data: t_vbuk like vbukvb occurs 0 with header line.
data: t_vbup like vbupvb occurs 0 with header line.
data: begin of t_orders occurs 0,
vbeln like vbak-vbeln.
data: end of t_orders.
----
initialization
----
initialization.
set date as default in dependence of the time.
if sy-uzeit >= '000000' and sy-uzeit <= '190000'.
p_vdatu = sy-datum.
else.
p_vdatu = sy-datum + 1.
endif.
----
Validate Selection Screen
----
at selection-screen.
if sy-batch eq space.
if sy-ucomm = 'ONLI'.
message e000(zwave) with
'Delivery Create Program can'
'ONLY be run in Background mode!!'.
stop.
endif.
endif.
----
START OF MAIN PROGRAM *
----
start-of-selection.
perform get_data.
*-- lock the plant and delivery date to prevent simulatenous delivery
*-- creations
perform lock_zfdwstatus_record using p_dwerk
p_vdatu.
perform create_deliveries.
*--- Unlock Status Record
perform unlock_zfdwstatus_record using p_dwerk
p_vdatu.
end-of-selection.
&----
*& Form create_deliveries
&----
form create_deliveries.
loop at t_orders.
clear d_vbeln.
refresh: t_vbak, t_vbap,
t_vbep, t_vbkd,
t_vbpa, t_vbuk,
t_vbup.
d_vbeln = t_orders-vbeln.
add 1 to d_task.
select * from vbak into table t_vbak
where vbeln = d_vbeln.
select * from vbap into table t_vbap
where vbeln = d_vbeln.
select * from vbep into table t_vbep
where vbeln = d_vbeln.
select * from vbkd into table t_vbkd
where vbeln = d_vbeln.
select * from vbpa into table t_vbpa
where vbeln = d_vbeln.
select * from vbuk into table t_vbuk
where vbeln = d_vbeln.
select * from vbup into table t_vbup
where vbeln = d_vbeln.
clear d_loop.
do.
select single * from vbfa where
vbelv = d_vbeln and
vbtyp_n = 'J'.
if sy-subrc eq 0.
exit.
else.
add 1 to d_loop.
call function 'SHP_VL10_DELIVERY_CREATE_PARA'
starting new task d_task
destination in group 'RFCGROUP'
exporting
if_ledat = p_vdatu
if_nur_vorgabe_pos = ' '
tables
it_vbak = t_vbak
it_vbap = t_vbap
it_vbep = t_vbep
it_vbuk = t_vbuk
it_vbup = t_vbup
it_vbkd = t_vbkd
it_vbpa = t_vbpa
exceptions
system_failure = 1
communication_failure = 2
resource_failure = 3
others = 4.
case sy-subrc.
when '0'.
exit.
when '3'.
if d_loop = 1.
wait up to '0.01' seconds.
elseif d_loop = 2.
wait up to '0.1' seconds.
else.
wait up to 1 seconds.
endif.
when others.
exit.
endcase.
endif.
enddo.
endloop.
if sy-subrc ne 0.
message i000(zwave) with 'No records for the given Selection!'.
else.
message s000(zwave) with 'Deliveries successfully processed!'.
endif.
endform. " create_deliveries
&----
*& Form get_data
&----
form get_data.
select distinct vbeln into table t_orders
from zwvbak_curr
where vbeln in s_vbeln and
vdatu = p_vdatu and
werks = p_dwerk.
*-- Ignore Orders for which Deliveries already created
loop at t_orders.
select single * from vbfa where
vbelv = t_orders-vbeln and
vbtyp_n = 'J'.
if sy-subrc eq 0.
delete t_orders.
endif.
endloop.
endform. " get_data
----
FORM lock_zfdwstatus_record *
----
........ *
----
--> P_WERKS *
--> P_VDATU *
--> P_ZZRUN *
----
form lock_zfdwstatus_record using p_dwerk
p_vdatu.
clear sy-subrc.
concatenate 'L' '00' into d_zzrun.
call function 'ENQUEUE_EZFDWSTATUS'
exporting
mode_zfdwstatus = 'E'
mandt = sy-mandt
werks = p_dwerk
vdatu = p_vdatu
zzrun = d_zzrun
exceptions
foreign_lock = 1
system_failure = 2
others = 3.
case sy-subrc.
when 0.
when 1.
message e000(zwave) with 'Wave Status Record Locked '
'by another process'
'Please try again later.'.
when others.
message e000(zwave) with 'Error Locking Status Record !'.
endcase.
endform. " lock_zfdwstatus_record
----
FORM unlock_zfdwstatus_record *
----
........ *
----
--> P_WERKS *
--> P_VDATU *
--> P_ZZRUN *
----
form unlock_zfdwstatus_record using p_dwerk
p_vdatu.
clear sy-subrc.
call function 'DEQUEUE_EZFDWSTATUS'
exporting
mode_zfdwstatus = 'E'
mandt = sy-mandt
werks = p_dwerk
vdatu = p_vdatu
zzrun = d_zzrun
_scope = '3'
_synchron = ' '.
if sy-subrc ne 0.
message e000(zwave) with 'Error Releasing Lock on Status Record!'.
endif.
endform. " unlock_zfdwstatus_record
‎2007 Jun 03 5:32 PM
I did not have code for RV_DELIVERY_CREATE ,i have program with SHP_VL10_DELIVERY_CREATE_PARA This function module
----
Table declaration *
----
tables: vbfa,
zwvbak_curr.
----
Selection Screen *
----
selection-screen begin of block b01 with frame title text-b01.
parameters: p_dwerk like zfdwstatus-werks default '1000' obligatory,
p_vdatu like zfdwstatus-vdatu obligatory.
selection-screen end of block b01.
selection-screen begin of block b02 with frame title text-b02.
select-options: s_vbeln for zwvbak_curr-vbeln.
selection-screen end of block b02.
----
Data definition *
----
data: d_task(5) type n.
data: d_vbeln like vbak-vbeln,
d_loop type i,
d_zzrun like zfdwstatus-zzrun.
data: t_vbak like vbak occurs 0 with header line.
data: t_vbap like vbapvb occurs 0 with header line.
data: t_vbep like vbepvb occurs 0 with header line.
data: t_vbkd like vbkdvb occurs 0 with header line.
data: t_vbpa like vbpavb occurs 0 with header line.
data: t_vbuk like vbukvb occurs 0 with header line.
data: t_vbup like vbupvb occurs 0 with header line.
data: begin of t_orders occurs 0,
vbeln like vbak-vbeln.
data: end of t_orders.
----
initialization
----
initialization.
set date as default in dependence of the time.
if sy-uzeit >= '000000' and sy-uzeit <= '190000'.
p_vdatu = sy-datum.
else.
p_vdatu = sy-datum + 1.
endif.
----
Validate Selection Screen
----
at selection-screen.
if sy-batch eq space.
if sy-ucomm = 'ONLI'.
message e000(zwave) with
'Delivery Create Program can'
'ONLY be run in Background mode!!'.
stop.
endif.
endif.
----
START OF MAIN PROGRAM *
----
start-of-selection.
perform get_data.
*-- lock the plant and delivery date to prevent simulatenous delivery
*-- creations
perform lock_zfdwstatus_record using p_dwerk
p_vdatu.
perform create_deliveries.
*--- Unlock Status Record
perform unlock_zfdwstatus_record using p_dwerk
p_vdatu.
end-of-selection.
&----
*& Form create_deliveries
&----
form create_deliveries.
loop at t_orders.
clear d_vbeln.
refresh: t_vbak, t_vbap,
t_vbep, t_vbkd,
t_vbpa, t_vbuk,
t_vbup.
d_vbeln = t_orders-vbeln.
add 1 to d_task.
select * from vbak into table t_vbak
where vbeln = d_vbeln.
select * from vbap into table t_vbap
where vbeln = d_vbeln.
select * from vbep into table t_vbep
where vbeln = d_vbeln.
select * from vbkd into table t_vbkd
where vbeln = d_vbeln.
select * from vbpa into table t_vbpa
where vbeln = d_vbeln.
select * from vbuk into table t_vbuk
where vbeln = d_vbeln.
select * from vbup into table t_vbup
where vbeln = d_vbeln.
clear d_loop.
do.
select single * from vbfa where
vbelv = d_vbeln and
vbtyp_n = 'J'.
if sy-subrc eq 0.
exit.
else.
add 1 to d_loop.
call function 'SHP_VL10_DELIVERY_CREATE_PARA'
starting new task d_task
destination in group 'RFCGROUP'
exporting
if_ledat = p_vdatu
if_nur_vorgabe_pos = ' '
tables
it_vbak = t_vbak
it_vbap = t_vbap
it_vbep = t_vbep
it_vbuk = t_vbuk
it_vbup = t_vbup
it_vbkd = t_vbkd
it_vbpa = t_vbpa
exceptions
system_failure = 1
communication_failure = 2
resource_failure = 3
others = 4.
case sy-subrc.
when '0'.
exit.
when '3'.
if d_loop = 1.
wait up to '0.01' seconds.
elseif d_loop = 2.
wait up to '0.1' seconds.
else.
wait up to 1 seconds.
endif.
when others.
exit.
endcase.
endif.
enddo.
endloop.
if sy-subrc ne 0.
message i000(zwave) with 'No records for the given Selection!'.
else.
message s000(zwave) with 'Deliveries successfully processed!'.
endif.
endform. " create_deliveries
&----
*& Form get_data
&----
form get_data.
select distinct vbeln into table t_orders
from zwvbak_curr
where vbeln in s_vbeln and
vdatu = p_vdatu and
werks = p_dwerk.
*-- Ignore Orders for which Deliveries already created
loop at t_orders.
select single * from vbfa where
vbelv = t_orders-vbeln and
vbtyp_n = 'J'.
if sy-subrc eq 0.
delete t_orders.
endif.
endloop.
endform. " get_data
----
FORM lock_zfdwstatus_record *
----
........ *
----
--> P_WERKS *
--> P_VDATU *
--> P_ZZRUN *
----
form lock_zfdwstatus_record using p_dwerk
p_vdatu.
clear sy-subrc.
concatenate 'L' '00' into d_zzrun.
call function 'ENQUEUE_EZFDWSTATUS'
exporting
mode_zfdwstatus = 'E'
mandt = sy-mandt
werks = p_dwerk
vdatu = p_vdatu
zzrun = d_zzrun
exceptions
foreign_lock = 1
system_failure = 2
others = 3.
case sy-subrc.
when 0.
when 1.
message e000(zwave) with 'Wave Status Record Locked '
'by another process'
'Please try again later.'.
when others.
message e000(zwave) with 'Error Locking Status Record !'.
endcase.
endform. " lock_zfdwstatus_record
----
FORM unlock_zfdwstatus_record *
----
........ *
----
--> P_WERKS *
--> P_VDATU *
--> P_ZZRUN *
----
form unlock_zfdwstatus_record using p_dwerk
p_vdatu.
clear sy-subrc.
call function 'DEQUEUE_EZFDWSTATUS'
exporting
mode_zfdwstatus = 'E'
mandt = sy-mandt
werks = p_dwerk
vdatu = p_vdatu
zzrun = d_zzrun
_scope = '3'
_synchron = ' '.
if sy-subrc ne 0.
message e000(zwave) with 'Error Releasing Lock on Status Record!'.
endif.
endform. " unlock_zfdwstatus_record
‎2007 Jun 03 7:21 PM
probably it is something wrong with logic of my program, because it is not creating at least deliveries... (vbak remains empty)
here I post my program, maybe you will see some obviuos mistakes...
&----
*&
*& REPORT ZINVOICEKK, v 2.0
*& Create date:
*&
&----
*& Last change date:
*&
&----
*& Comments:
*&
&----
REPORT ZINVOICEKK NO STANDARD PAGE HEADING line-size 195 line-count 50.
CONSTANTS: C_VKORG TYPE I VALUE 9000, " Organization
C_VTWEG TYPE I VALUE 90, " Distribution channel
C_SPART TYPE I VALUE 40. " Division
DATA: I_VBAK TYPE VBAK OCCURS 0 WITH HEADER LINE,
WA_VBAK TYPE VBAK.
DATA: LV_VBELV TYPE VBFA-VBELV,
VBSK_I LIKE VBSK.
For creating delivery
DATA: t_vbak like vbak occurs 0 with header line.
DATA: t_vbap like vbapvb occurs 0 with header line.
DATA: t_vbep like vbepvb occurs 0 with header line.
DATA: t_vbfa like vbfavb occurs 0 with header line.
DATA: t_vbfs like vbfs occurs 0 with header line.
DATA: t_vbkd like vbkdvb occurs 0 with header line.
DATA: t_vbls like vbls occurs 0 with header line.
DATA: t_vbpa like vbpavb occurs 0 with header line.
DATA: t_vbuk like vbukvb occurs 0 with header line.
DATA: t_vbup like vbupvb occurs 0 with header line.
DATA: WA_VBSK LIKE VBSK OCCURS 1 WITH HEADER LINE,
WA_VBSKE LIKE VBSK OCCURS 1 WITH HEADER LINE.
VBELN - main nr for delivery
DATA: d_vbeln like vbak-vbeln.
DATA: d_task(5) type n.
Date values for invoices
DATA: GV_DELIVERY_DATE TYPE RV60A-FBUDA,
GV_INVOICE_DATE TYPE RV60A-FKDAT,
GV_PRICING_DATE TYPE RV60A-PRSDT,
GV_SELECT_DATE TYPE RV60A-FKDAT.
Invoice type
DATA: GV_INVOICE_TYPE TYPE RV60A-FKART,
GV_VBELN TYPE VBAK-VBELN.
For creating invoice and invoice list
DATA: XKOMFK LIKE KOMFK OCCURS 0 WITH HEADER LINE, " Billing Communications Table
XKOMV LIKE KOMV OCCURS 0 WITH HEADER LINE, " Pricing Communications-Condition Record
XTHEAD LIKE THEADVB OCCURS 0 WITH HEADER LINE, " Reference Structure for XTHEAD
XVBSK LIKE VBSK OCCURS 0 WITH HEADER LINE, " Error Log for Collective Processing
XVBFS LIKE VBFS OCCURS 0 WITH HEADER LINE, " Error Log for Collective Processing
XVBPA LIKE VBPAVB OCCURS 0 WITH HEADER LINE, " Reference structure for XVBPA/YVBPA
XVBRK LIKE VBRKVB OCCURS 0 WITH HEADER LINE, " Reference Structure for XVBRK/YVBRP - Billing Document: Header Data
XVBRP LIKE VBRPVB OCCURS 0 WITH HEADER LINE, " Reference Structure for XVBRP/YVBRP - Billing Document: Item Data
XVBRL LIKE VBRL OCCURS 0 WITH HEADER LINE, " Sales Document: Invoice List
XVBSS LIKE VBSS OCCURS 0 WITH HEADER LINE, " Collective Processing: Sales Documents
XKOMFKGN LIKE KOMFKGN OCCURS 0 WITH HEADER LINE. " Billing Interface: Communication Table
Posting goods issue (PGI)
DATA: I_VBKOK LIKE VBKOK,
I_PROTT LIKE PROTT OCCURS 0 WITH HEADER LINE.
&----
*& BEGIN
&----
REFRESH: XKOMFK, XKOMV,
XTHEAD, XVBFS,
XVBPA, XVBRK,
XVBRP, XVBSS.
CLEAR: XKOMFK, XKOMV,
XTHEAD, XVBFS,
XVBPA, XVBRK,
XVBRP, XVBSS,
VBSK_I.
&----
*& Take sales orders from VBAK
&----
SELECT *
FROM VBAK INTO TABLE I_VBAK
WHERE VBAK~VKORG = C_VKORG
AND VBAK~VTWEG = C_VTWEG
AND VBAK~SPART = C_SPART.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
LOOP AT I_VBAK INTO WA_VBAK.
SELECT VBELV
FROM VBFA INTO LV_VBELV
WHERE VBELV = WA_VBAK-VBELN.
ENDSELECT.
IF SY-SUBRC = 0.
ELSE.
&----
*& VBSK
&----
CLEAR WA_VBSK.
WA_VBSK-MANDT = SY-MANDT.
WA_VBSK-ERNAM = SY-UNAME.
WA_VBSK-ERDAT = SY-DATUM.
WA_VBSK-UZEIT = SY-UZEIT.
&----
*& Create delivery
&----
CLEAR d_vbeln.
CLEAR XKOMFK.
REFRESH: t_vbak, t_vbap,
t_vbep, t_vbkd,
t_vbpa, t_vbuk,
t_vbup, t_vbfa,
t_vbfs, t_vbls,
XKOMFK.
d_vbeln = WA_VBAK-VBELN.
add 1 to d_task.
select * from vbak into table t_vbak
where vbeln = d_vbeln.
select * from vbap into table t_vbap
where vbeln = d_vbeln.
select * from vbep into table t_vbep
where vbeln = d_vbeln.
select * from vbkd into table t_vbkd
where vbeln = d_vbeln.
select * from vbpa into table t_vbpa
where vbeln = d_vbeln.
select * from vbuk into table t_vbuk
where vbeln = d_vbeln.
select * from vbup into table t_vbup
where vbeln = d_vbeln.
CALL FUNCTION 'RV_DELIVERY_CREATE'
EXPORTING
SELEKTIONSDATUM = SY-DATUM
VBSK_I = WA_VBSK
IF_SYNCHRON = 'X'
IF_NO_COMMIT = ''
IMPORTING
VBSK_E = WA_VBSKE
TABLES
LVBAK = t_vbak
LVBAP = t_vbap
LVBEP = t_vbep
LVBFA = t_vbfa
LVBFS = t_vbfs
LVBKD = t_vbkd
LVBLS = t_vbls
LVBPA = t_vbpa
LVBUK = t_vbuk
LVBUP = t_vbup.
IF SY-SUBRC <> 0.
ROLLBACK WORK.
ELSE.
COMMIT WORK.
ENDIF.
&----
*& CALL WS_DELIVERY_UPDATE
&----
CALL FUNCTION 'WS_DELIVERY_UPDATE'
EXPORTING
VBKOK_WA = I_VBKOK
SYNCHRON = 'X'
NO_MESSAGES_UPDATE = ' '
UPDATE_PICKING = 'X'
COMMIT = ' '
DELIVERY = d_vbeln
NICHT_SPERREN = 'X'
IF_ERROR_MESSAGES_SEND_0 = 'X'
TABLES
PROT = I_PROTT
EXCEPTIONS
ERROR_MESSAGE = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
ROLLBACK WORK.
ELSE.
COMMIT WORK.
ENDIF.
&----
*& CALL RV_INVOICE_CREATE
&----
GV_DELIVERY_DATE = '01/01/2007'.
GV_INVOICE_DATE = '01/01/2007'.
GV_INVOICE_TYPE = 'G2'.
GV_PRICING_DATE = '01/01/2007'.
GV_SELECT_DATE = '01/01/2007'.
VBSK_I-SMART = 'F'.
XKOMFK-VBELN = d_vbeln.
XKOMFK-VBTYP = 'J'.
APPEND XKOMFK.
CALL FUNCTION 'RV_INVOICE_CREATE'
EXPORTING
DELIVERY_DATE = GV_DELIVERY_DATE
INVOICE_DATE = GV_INVOICE_DATE
INVOICE_TYPE = GV_INVOICE_TYPE
PRICING_DATE = GV_PRICING_DATE
VBSK_I = XVBSK
SELECT_DATE = GV_SELECT_DATE
IMPORTING
VBSK_E = XVBSK
TABLES
XKOMFK = XKOMFK
XKOMV = XKOMV
XTHEAD = XTHEAD
XVBFS = XVBFS
XVBPA = XVBPA
XVBRK = XVBRK
XVBRP = XVBRP
XVBSS = XVBSS.
IF SY-SUBRC = 0.
COMMIT WORK.
ELSE.
ROLLBACK WORK.
ENDIF.
&----
*& CALL RV_INVOICE_LIST_CREATE
&----
CALL FUNCTION 'RV_INVOICE_LIST_CREATE'
EXPORTING
DELIVERY_DATE = GV_DELIVERY_DATE
INVOICE_DATE = GV_INVOICE_DATE
INVOICE_TYPE = GV_INVOICE_TYPE
PRICING_DATE = GV_PRICING_DATE
VBSK_I = XVBSK
WITH_POSTING = ' '
I_NO_VBLOG = ' '
IMPORTING
VBSK_E = XVBSK
TABLES
XKOMFK = XKOMFK
XKOMV = XKOMV
XTHEAD = XTHEAD
XVBFS = XVBFS
XVBPA = XVBPA
XVBRK = XVBRK
XVBRL = XVBRL
XVBSS = XVBSS.
IF SY-SUBRC = 0.
COMMIT WORK.
ELSE.
ROLLBACK WORK.
ENDIF.
ENDIF.
ENDLOOP.
‎2007 Jun 03 7:29 PM
in fact vbak is not empty, but there are no my records... or I am not even sure how to check if each FM creates appropriate records, because do not know what tables to check...
BR, M.
‎2007 Jun 04 7:12 AM
Hi!
main issues that are still open for me:
1. how to manage pricing process? I mean that is it enough just to call RV_CREATE_INVOICE to create Credit / Debit memo invoices?
Is it possible to determine if it will be Credit or Debit memo invoice before calling FM for it if I have a Sales Order created? I mean how Sales order is related with pricelists and so on...
2. how to check the result of such FMs:
RV_DELIVERY_CREATE (vbak?)
WS_DELIVERY_UPDATE
RV_INVOICE_CREATE
RV_INVOICE_LIST_CREATE
I mean what tables to check?
Help will be rewarded.
Kind regards, Mindaugas