Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member184681
Active Contributor

Working with a custom IDoc scenario once, I have noticed a strange IDoc behaviour of IDoc segments that contain fields longer than 132 characters. First of all, I developed the whole scenario without problems when defining IDoc segment, IDoc type, and releasing them both. But when it came to testing, I have noticed in IDoc monitors that the contents seem to get truncated:

I already knew that there was a limitation for the whole IDoc segment contents size – it cannot exceed 1000 characters (precisely: because of the length of the SDATA field of EDID4 database table that stores IDoc segments). But is there another limitation for the individual field size?

Yet another surprise was when I came to realize that the data is processed properly, even though it is not visible there in the IDoc. How was that possible at all? This was where I started detailed investigation. I started by checking all IDoc monitors in ECC that I could think of, let me only mention we02 and bd87, but without success. Then I tried to outsmart the system and see the contents directly in the DB table EDID4, but this was yet another disappointment, as you cannot display more than 128 characters in an ALV Grid column (see OSS Note 422660 - ALV grid: Field lengths are limited to 128 characters).

The next thought was: I’ll check the IDoc contents in PI. So, without lots of hope I went to sxi_monitor and I got surprised again, as the whole field contents were visible there:

OK, fine. At least I know why my scenario works as designed. But is it really the only way to check it? Can’t I display the data in ECC as well?

I checked OSS notes once again. And again without success. There was this Note 600293 - IDoc: Editing long fields of a segment incorrect, but it was quite old, and it was doing right the opposite thing. It disabled going to change mode for fields longer than 132 characters (because they are not handled properly anyway). And there was another one, Note 1148717 - WE02: Not limiting editing of long fields so strictly. This was somehow close to what I wanted to do. But all in all, I did not want to EDIT any IDoc contents, just display and verify them, so I decided to search a bit more.

To my surprise (yet another time), it appeared that one of the simples solutions was the successful one. It was enough to call the function module IDOC_READ_COMPLETELY. It gives you the IDoc contents as it is, without further conversions, so the data is not truncated. You might want to call it directly in se37, or implement a trivial ABAP report for displaying IDoc contents with the WRITE statement, which – although being old and much less useful than ALV Grid in normal cases – gives you what was required in this particular situation. For instance, you could implement it like that:

*&---------------------------------------------------------------------*

*& Report  Z_IDOC_SHOW

*&---------------------------------------------------------------------*

REPORT  z_idoc_show.

TYPES:

     BEGIN OF lty_abap_compdescr,

          length TYPE i,

          decimals TYPE i,

          type_kind TYPE c LENGTH 1,

          name TYPE c LENGTH 30,

     END OF lty_abap_compdescr.

DATA:

     lit_idoc_data TYPE STANDARD TABLE OF edidd,

     ltp_string_temp TYPE string,

     tb_struct TYPE REF TO cl_abap_structdescr.

FIELD-SYMBOLS:

     <lwa_idoc_data> LIKE LINE OF lit_idoc_data,

     <lwa_segment> TYPE ANY,

     <lwa_idoc_field> TYPE ANY,

     <lwa_structure> TYPE lty_abap_compdescr.

SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-t01.

     PARAMETERS: pa_idoc TYPE edi_docnum OBLIGATORY.

SELECTION-SCREEN END OF BLOCK blk1.

AT SELECTION-SCREEN.

* check authorization here

START-OF-SELECTION.

     CALL FUNCTION 'IDOC_READ_COMPLETELY'

          EXPORTING

               document_number = pa_idoc

          TABLES

               int_edidd = lit_idoc_data

          EXCEPTIONS

               document_not_exist = 1

               document_number_invalid = 2

               OTHERS = 3.

IF sy-subrc = 0.

     LOOP AT lit_idoc_data ASSIGNING <lwa_idoc_data>.

          FORMAT COLOR = 1. "heading

          WRITE: / 'SEGMENT:   ', <lwa_idoc_data>-segnam.

          FORMAT COLOR = 0. "normal

          ASSIGN COMPONENT 'SDATA' OF STRUCTURE <lwa_idoc_data>

               TO <lwa_segment>

               CASTING TYPE (<lwa_idoc_data>-segnam).

          DO.

               tb_struct ?= cl_abap_typedescr=>describe_by_data( <lwa_segment> ).

               ASSIGN COMPONENT sy-index OF STRUCTURE <lwa_segment> TO <lwa_idoc_field>.

               IF sy-subrc = 0.

                    READ TABLE tb_struct->components ASSIGNING <lwa_structure> INDEX sy-index.

                    ltp_string_temp = <lwa_structure>-name.

                    WRITE: / ltp_string_temp, ' = ', <lwa_idoc_field>.

               ELSE.

                    EXIT.

               ENDIF.

          ENDDO.

     ENDLOOP.

ELSE.

     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

The result can be as follows:

which is exactly what was the goal :smile: .

2 Comments
Labels in this area