Sapass

 Simplify SAP R/3 development with Excel VBA/VB RFC  
Home> UserExit>V56ARCHV



Index

V56ARCHV

User Exits for SD Transport Processing
This user exit is for implementing customer-specific checks for archiving shipments.

It is called up in the SDVTTKWR archiving program after all the checks have been run in the standard system.

If you call up the archiving program with the 'Detailed log' option, the shipments listed on the screen also include those that cannot be archived (the detailed log includes ALL checks). If the above option is not selected, all the listed shipments can be archived according to the criteria in the standard system.

The exit consists of:

  • EXIT_SDVTTKWR_001
    This is for reading shipments that need checking in advance with a collective access to the database. The function module receives the database tables that have already been read in the archiving program as table parameters.
    TABLES:
    • I_VTTK STRUCTURE VTTK
      Shipment header data
    • I_VTTP STRUCTURE VTTP
      Shipment items

  • EXIT_SDVTTKWR_002
    checks each shipment document individually. This check should access the data read in the previous EXIT_SDVTTKWR_001 (this data should be created globally in the TOP Include of the function group).
    IMPORTING:
    • I_TKNUM LIKE VTTK-TKNUM
      is the shipment document that is to be checked

EXPORTING:

  • E_IS_NOT_ARCHIVABLE TYPE C
    specifies that the document cannot be archived
  • E_MESSAGE_NUMBER LIKE T100-MSGNR
    is the message that is issued in the log. Note the following conventions: The message must be created in message class VW (messages from number 900) and they should contain the shipment number as the first variable (&1).
    Example:
    901: Billing document &3 for delivery &2 in shipment &1 has not been posted
  • E_MESSAGE_VARIABLE2 TYPE C
    E_MESSAGE_VARIABLE3 TYPE C
    are the parameters &2 and &3 in this message.
Example:

The following additional check should also be run:
A shipment can be archived once all the deliveries for that shipment have been completely billed and all the relevant billing documents have been completely posted to Financial Accounting.

The example coding has been created to produce optimal performance because these kind of additional checks can considerably increase the runtime of the archiving program.

  • Only collective accesses are made in EXIT_SDVTTKWR_001 ('SELECT FOR ALL ENTRIES')
  • The global data G_VBUK_DELIVERY and G_VBRK_INVOICE only contain the really necessary data. The SELECT statemnets that complete these tables contain the additional 'INTO CORRESPONDING FIELDS OF TABLE', so that only the necessary data is read.
  • In EXIT_SDVTTKWR_002 the BINARY SEARCH accesses all the internal tables.
The global data definitions are as follows:


data:
g_vttp like vttp occurs 0 with header line,
g_vbfa like vbfa occurs 0 with header line,
* delivery status data: only small portion of delivery
* status data is read from the database (performance)
begin of g_vbuk_delivery occurs 0,
vbeln like vbuk-vbeln,
fkstk like vbuk-fkstk,
end of g_vbuk_delivery,
* invoice data: only small portion of invoice data
* is read from the database (performance)
begin of g_vbrk_invoice occurs 0,
vbeln like vbrk-vbeln,
rfbsk like vbrk-rfbsk,
end of g_vbrk_invoice.

Funktionsbaustein EXIT_SDVTTKWR_001 enth舁t das folgende Coding:

data:
begin of l_deliveries_invoiced occurs 0,
vbeln like vbuk-vbeln,
end of l_deliveries_invoiced.


* refresh all global data:
refresh:
g_vttp,
g_vbfa,
g_vbuk_delivery,
g_vbrk_invoice.

* only continue when there are any deliveries in i_vttp
check not i_vttp[] is initial.

* fill table g_vttp:
g_vttp[] = i_vttp[].

* read the status of delivery for later evaluation
select * from vbuk into corresponding fields of table g_vbuk_delivery
for all entries in g_vttp
where vbeln = g_vttp-vbeln.

* for those deliveries which are completely invoiced find out the
* invoive numbers:
loop at g_vbuk_delivery where fkstk = 'C'.
l_deliveries_invoiced-vbeln = g_vbuk_delivery-vbeln.
append l_deliveries_invoiced.
endloop.

* are there any deliveries left ?
check not l_deliveries_invoiced[] is initial.

* find out which invoices follow these deliveries
select * from vbfa into table g_vbfa
for all entries in l_deliveries_invoiced
where vbelv = l_deliveries_invoiced-vbeln and
( vbtyp_n = 'M' or
vbtyp_n = 'P' or
vbtyp_n = 'N' or
vbtyp_n = 'O' or
vbtyp_n = 'S' or
vbtyp_n = '3' or
vbtyp_n = '4' or
vbtyp_n = '5' or
vbtyp_n = '6' or
vbtyp_n = 'U' ).

* now read the accounting status for these invoices from database
if not g_vbfa[] is initial.
select * from vbrk into corresponding fields of table g_vbrk_invoice
for all entries in g_vbfa
where vbeln = g_vbfa-vbeln.
endif.

* sort tables (for later access via binary search)
sort:
g_vttp,
g_vbfa,
g_vbuk_delivery,
g_vbrk_invoice.

Funktionsbaustein EXIT_SDVTTKWR_002 enth舁t das folgende Coding:


* assumption: shipment is archivable
e_is_not_archivable = ' '.

* are there any deliveries in this shipment ?
read table g_vttp with key tknum = i_tknum binary search.
check sy-subrc = 0.

* loop at all deliveries in this shipment
loop at g_vttp from sy-tabix.

* exit this loop when deliveries for other shipment occur:
if g_vttp-tknum ne i_tknum. exit. endif.

* find out the invoice status of this delivery
read table g_vbuk_delivery with key vbeln = g_vttp-vbeln
binary search.

* when this delivery is not invoice relevant, skip it:
if g_vbuk_delivery-fkstk = ' '.
continue.
endif.

* is the invoice status of this delivery complete ?
if g_vbuk_delivery-fkstk = 'A' or g_vbuk_delivery-fkstk = 'B'.
e_is_not_archivable = 'X'.
e_message_number = '901'.
* message 901 must be created by the customer. Example:
* 901(VW): delivery &2 in shipment &1 is not completely invoiced
e_message_variable2 = g_vttp-vbeln.
e_message_variable3 = space.
* further checks for this shipment are not necessary
exit.
endif.

* invoice status = 'C' for this delivery. Check subsequent invoices
* find out which invoice documents follow for each delivery
read table g_vbfa with key vbelv = g_vttp-vbeln binary search.
check sy-subrc = 0.

* for all invoice documents for this delivery check it's status
loop at g_vbfa from sy-tabix.

* exit this loop when invoice belongs to another delivery
if g_vbfa-vbelv ne g_vttp-vbeln. exit. endif.

* read corresponding status for this invoice:
read table g_vbrk_invoice with key vbeln = g_vbfa-vbeln
binary search.
if sy-subrc = 0.

* is the accounting status OK ?
if g_vbrk_invoice-rfbsk ne 'C'.
e_is_not_archivable = 'X'.
e_message_number = '490'.
* message 902 must be created by the customer. Example:
* 902(VW): Invoice &3 for delivery &2 in shipment &1 is
* not completely accounted.
e_message_variable2 = g_vttp-vbeln.
e_message_variable3 = g_vbrk_invoice-vbeln.
* no further checks for this delivery necessary
exit.
endif.

endif.

endloop.
Function/Program:

  • EXIT_SDVTTKWR_001: Shipment Archiving: Customer-Defined Checks: Prefetch
  • EXIT_SDVTTKWR_002: Enhancement of Shipment Archiving: Checks Per Shipment

02-Oct-2005