SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software
Development resources, articles, tutorials, code samples, tools and downloads for SAP HANA and ABAP, HANA Database, SQLScript, SAP UI5, Screen Personas, Web Dynpro, Workflow

Read LIKP Delivery Data from Archive using ABAP Code

This ABAP tutorial shows how to read LIKP delivery data from archive using ABAP function module ASH_RV_LIKP_READ Archived delivery documents can not be found by querying SAP LIKP transparent table (SD Document: Delivery Header Data) In case of a requirement to read archived delivery data from SAP system, ABAP developers can use the ASH_RV_LIKP_READ ABAP function module as demonstrated in this tutorial.

If you have a delivery document which is archived, you will not be able to query LIKP database table and return data by using the VBELN number. The result SAP user will get is "No table entries found for specified key"

On the other hand, using SAP transaction code VL03N and using the delivery document number it is still possible to display the delivery data. The VL03N transaction screen will inform you that the delivery data is read from archive.

For ABAP programmer, the ABAP function module ASH_RV_LIKP_READ enables it to read delivery data including LIKP, LIPS, etc using ABAP code programmatically. Here is how.

Create a new sample ABAP report using SE38 ABAP Editor transaction.
Using Pattern button add new statement for function module call to ASH_RV_LIKP_READ
If you check the output return parameters, there is more than you can expect to read about a delivery document.

I will only read the delivery header document for simplicity of this ABAP tutorial.

What makes it easy to read archived delivery document from archive is to use only the delivery number VBELN as input to the ABAP function module call.
Define a new borident type structure and assign the delivery number to the OBJKEY field of the borident structure.
Then pass this variable as input value for i_borident parameter of the ASH_RV_LIKP_READ function module. That's all

DATA ls_borident LIKE borident.
DATA lt_likp TYPE TABLE OF likp.

ls_borident-OBJKEY = '8852097345'.

CALL FUNCTION 'ASH_RV_LIKP_READ'
 EXPORTING
* I_ARCHIVEKEY =
* I_OFFSET =
  i_borident = ls_borident
 TABLES
  et_likp = lt_likp
* ET_LIPS =
* ET_VBUK =
* ET_VBUP =
* ET_VBFA =
* ET_VBPA =
* ET_VBPA3 =
* ET_SADR =
* ET_ADDR1_VAL =
* ET_VBUV =
* ET_EIKP =
* ET_EIPO =
* ET_KONV =
* ET_CDHDR =
* ET_CDRED =
* ET_LIPSRF =
* ET_CD_DOCFLOW =
 EXCEPTIONS
  NOT_IN_INFOSTRUCTURE = 1
  NOT_IN_ARCHIVE = 2
  NO_INSTRUCTURE_DEFINED = 3
  OTHERS = 4
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
Code

I implemented the Exceptions otherwise if the delivery document cannot be found in the archive, the function module displays a popup screen to display the exception message. Since this code will run as a background program, I did not wanted the ABAP report to display messages in dynpro.

You can test the ABAP function module ASH_RV_LIKP_READ in action using SE37 tcode Test Function Module screen too. Here is what I got as output.

read archived delivery document using ABAP function module
How to read LIKP delivery document from archive in SAP using ABAP function module

Although it is possible to use the ASH_RV_LIKP_READ ABAP function module using I_ARCHIVEKEY and I_OFFSET input parameters, it requires more steps to fetch these values for each delivery document number and its positions.

First SAP table AIND_STR1 (Archive Info Structures) has to be queried for a valid archive info structure for SAP standard RV_LIKP object type. Then AIND_STR2 table should be filtered for GENTAB field which returns the "Table where an archive information stucture is stored"

After finding the name of the archive table where the related archived data is stored, this table can be searched for the related key and offset data using the delivery document number VBELN and the POSNR item position.

Here is an other ABAP sample code.

TYPES:
 BEGIN OF gty_archive,
  archivekey TYPE arkey, " Key for Archive File
  archiveofs TYPE admi_offst, " Archive file data object offset
 END OF gty_archive.
DATA ls_archive TYPE gty_archive.

SELECT SINGLE gentab
 INTO @DATA(lv_archive_table)
FROM aind_str1
INNER JOIN aind_str2
 ON aind_str1~archindex = aind_str2~archindex
WHERE aind_str1~object = 'RV_LIKP'
 aind_str1~itype = 'I'
 AND aind_str1~otyp = 'O'
 AND aind_str2~active = 'D'.

SELECT SINGLE *
 FROM (lv_archive_table)
 INTO CORRESPONDING FIELDS OF ls_archive
 WHERE vbeln = '8852097345'. "i_vbeln_vl

CALL FUNCTION 'ASH_RV_LIKP_READ'
 EXPORTING
  i_archivekey = ls_archive-archivekey
  i_offset = ls_archive-archiveofs
* I_BORIDENT = ls_borident
 TABLES
  et_likp = lt_likp
* ET_LIPS =
* ET_VBUK =
* ET_VBUP =
* ET_VBFA =
* ET_VBPA =
* ET_VBPA3 =
* ET_SADR =
* ET_ADDR1_VAL =
* ET_VBUV =
* ET_EIKP =
* ET_EIPO =
* ET_KONV =
* ET_CDHDR =
* ET_CDRED =
* ET_LIPSRF =
* ET_CD_DOCFLOW =
 EXCEPTIONS
  NOT_IN_INFOSTRUCTURE = 1
  NOT_IN_ARCHIVE = 2
  NO_INSTRUCTURE_DEFINED = 3
  OTHERS = 4
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
Code


SAP HANA and ABAP

Install SAP Free
CRM Companies List
Web Based CRM Software


Copyright © 2004 - 2021 Eralper YILMAZ. All rights reserved.