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

How to Display IDOC Message Type Field Properties

Use SAP transaction WE30 Develop IDoc Types to display, change or create an IDoc type in ABAP or display Idoc segments, structures, properties, and fields in Idoc segment with each field's properties like data element and export length.

Frequently ABAP developers work with IDOC outputs to export or import data between different systems. To get familiar with IDOC document type, Idoc segments, segment fields and segment field attributes like length and data type ABAP programmers can use WE30 SAP transaction as a starting point.

Recently I experienced a data truncate problem on one of the invoice Idoc outputs. A note Idoc segment field was populated with a string which has a length of more than 255 characters. Unfortunately, although the size of an IDOC segment was 1000 characters, only a limited portion of the string variable was displayed on the IDOC segment note field.

I know that there are some limitation of displaying the contents of IDOC on SAP Idoc related transaction code screens. To be sure, I choose to export Idoc data as text file and download Idoc export file to my desktop. The Idoc segment was not displaying all string data.

First I decided to check if there is a size limit on relaed IDoc segment field where I write string variable.

To display the intermediate document's segment attributes, I has to know the Idoc message type of that IDOC document.

There are a few ways to learn the message type of an Idoc document.


SAP IDoc Message Type on WE02 IDoc List

Execute WE02 IDoc List transaction screen and list the Idoc document which you are working on.
On the Selected IDocs list ALV screen, you will see a column titled as "Message Type" showing the message type of related Idoc document.

SAP WE02 IDoc list with message type attribute

After you learn the message type, we can now continue in SAP to display structures and fields of that IDoc type.


Get IDOC Message Type in ABAP Code

ABAP programmer can query SAP table EDIDC Control record (IDoc) for message type using below ABAP code sample. Below ABAP Select statement reads message type from EDIDC IDoc document control table where main properties of the Idoc is stored. Also the message type is stored in ABAP variable lv_idoc_message_type for later use.

DATA lv_docnum TYPE edi_docnum VALUE '6782965'. " IDoc number

SELECT SINGLE mestyp INTO @DATA(lv_idoc_message_type)
 FROM edidc " EDIDC Control record (IDoc) SAP table
 WHERE docnum = @lv_docnum.
Code

Display IDOC Message Type Segment Fields

Execute WE30 transaction code for Develop IDoc Types initial screen.

Type the IDoc type name in "Obj. Name" input text field.

Choose "Basic type" or "Extension" on "Development Object" section on the screen.

Press F7 Display shortcut key for displaying the basic Idoc type.
Here is a sample screen for INVOIC02 Idoc type used for invoices and billing documents exchange between different systems.

SAP WE30 IDoc object types screen for IDoc message type

Here is a the INVOIC02 Idoc message type which is used for invoice and other billing documents exchange between an SAP system and third party systems and partners. As you see in below screenshot, IDOC segment types used for the IDOC document is listed in treeview structure.

display IDoc message type

For more detail about the segment and the segment fields, double click on the target segment type. For example, to display item partner detail transferred via IDOC document, double click on "E1EDPA1 IDoc: Doc.item partner information" segment type.

SAP IDoc segment properties

ABAP developer can see that this segment can repeat it self maximum 20 times for an item. Also for each item at least 1 partner information segment should exist.

Now click on "Segment editor" button. This button will lead ABAP programmer to the list of fields in that segment type.

display SAP Idoc messages segment type definition

ABAP programmer can also display segment field list using SAP tcode WE31 and then by displaying F7 Display button, too. On WE31 transaction code initial screen, you may see a list of definitions showing segment type modifications. For example on E2EDPA1 you can see 39 fields are used for that IDOC segment type. On the other hand, the current version E2EDPA1003 has 44 fields defined.


Use ABAP Function Module IDOC_TYPE_COMPLETE_READ for Segment Fields

To get Idoc segment fields in detail like data type and field names etc, ABAP programmers can call ABAP function module IDOC_TYPE_COMPLETE_READ as shown in below sample code.

DATA lt_idoc_struct TYPE ledid_t_idoc_struct.
DATA lt_segments TYPE ledid_t_segment.
DATA lt_segment_struct TYPE ledid_t_segment_struct.

CALL FUNCTION 'IDOC_TYPE_COMPLETE_READ'
 EXPORTING
  * RELEASE = SY-SAPRL
  * APPLREL =
  * STRUCT_TYPE = 'B'
  idoctype = lv_idoc_message_type
  * VERSION = '3'
  * IMPORTING
  * IDOC_TYPE =
 TABLES
  idoc_struct = lt_idoc_struct
  segments = lt_segments
  segment_struct = lt_segment_struct
 EXCEPTIONS
  idoctype_unknown = 1
  idocstruct_unknown = 2
  segment_data_missing = 3
  illegal_struct_type = 4
  OTHERS = 5.
Code

Then using ABAP Loop statement, programmer can display or list field attributes using like ls_segment_struct-field_attrib-rollname, ls_segment_struct-field_attrib-datatype, ls_segment_struct-field_attrib-extlen, etc.
I'll soon publish a more detailed ABAP tutorial on reading IDoc message segment field attributes using function module IDOC_TYPE_COMPLETE_READ.

After ABAP programmer display each segment field's properties like length, it is easier to identify the reason of a string data truncate problem. For my case, I see that the note segment field has a length of 400 characters wide. But I was not able to store more than 255. The reason for such an error can be related with variables and their data types. Within ABAP codes processing IDoc output, the variables used in ABAP program should be truncating string value and limiting the length according to its data type limits.

I hope SAP users can now use WE30 and WE31 SAP transaction codes better now to display Idoc message type properties and attributes of each segment field like field length, etc.



SAP HANA and ABAP

Install SAP Free
CRM Companies List
Web Based CRM Software


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