Skip to Content
Author's profile photo Martin Grob

HowTo extract Order long text

Extracting Order number and Description is pretty straight forward when you use the standard datasource 0COORDER_TEXT
provided by the content.

What if you need to include the “long text” which sits behind the document icon?

A.png

B.png

For that we make use of the functionmodul READ_TEXT in CMOD.

You have two options either you extend the standard datasource 0COORDER_ATTR or opt for an additional datasource. In this
example we use
ZBW_COORDER_ATTR as additional datasource.

  1. Create the datasource ZBW_COORDER_ATTR which basically has only AUFNR and TXTLG as fields.
  2. Next we need a CMOD entry reading through READ_TEXT the desired additional  text. You can modify the code that it transfers the language code.

         We only needed english and if it doesn’t exist try german. In the end we map it to our txtlg. Unfortunately you will be restricted to 60 CHAR.

Detail on READ_TEXT

For Order Description we need LTXT and the Object AUFK.

        CALL FUNCTION ‘READ_TEXT’
            
EXPORTING
              
CLIENT             = ‘100’
              
ID                      = ‘LTXT’
              
LANGUAGE      = l_text_langu
               NAME       
= l_object_name
               OBJECT     
= ‘AUFK’

In the end we fill  l_object_name with the order number.  ( l_object_name = <fs_zbw_coorder_attr>AUFNR.)

C.png

Submitting those parameters delivers you the “Additional TEXT”

D.png

Putting it all in CMOD:

———————————————————————————–

   WHEN ‘ZBW_COORDER_ATTR’.
     LOOP AT i_t_data ASSIGNING <fs_zbw_coorder_attr>.
** derive order description, max 560 chars, if LTEXT = X we take always the first line only, the others are history
       IF <fs_zbw_coorder_attr>LTEXT = RS_C_TRUE.
* call function module to read the order text
         CLEAR lt_text_lines.
         l_text_langu = ‘E’. ” English default
         l_object_name = <fs_zbw_coorder_attr>AUFNR.

         DO 2 TIMES. “first english, then german
           CALL FUNCTION ‘READ_TEXT’
             EXPORTING
               CLIENT              = ‘100′
               ID                       = ‘LTXT’
               LANGUAGE       = l_text_langu
               NAME                 = l_object_name
               OBJECT             = ‘AUFK’
*         IMPORTING
*           HEADER                  = HTEXT
             TABLES
               LINES                   = lt_text_lines
             EXCEPTIONS
               ID                                      = 1
               LANGUAGE                     = 2
               NAME                               = 3
               NOT_FOUND                   = 4
               OBJECT                           = 5
               REFERENCE_CHECK     = 6
               WRONG_ACCESS_TO_ARCHIVE = 7
               OTHERS                            = 8.

           IF SYSUBRC = 0.
             EXIT.
           ENDIF.
           l_text_langu = ‘D’. ” set language to german for second try
         ENDDO.

         IF NOT lt_text_lines IS INITIAL.
           READ TABLE lt_text_lines INTO lr_text_lines INDEX 1.
           <fs_zbw_coorder_attr>txtlg = lr_text_linesTDLINE(60).
         ENDIF.
       ENDIF.
ENDCASE.

———————————————————————————–

That’s it map your datasource to 0coorder with an additonal infoobject with holds the long text and you are done..

Should you want to extract more than 60 Char you can follow this blog.

Assigned Tags

      17 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Raman Korrapati
      Raman Korrapati

      Really helpful one. Simple and very well presented.

      Thanks for sharing and making Martin.

      Raman

      Author's profile photo Anshu Lilhori
      Anshu Lilhori

      Hi,

      Nice to be documented..Lately implemented the same to get sales order rejection text.

      Regards,

      AL

      Author's profile photo Jรผrgen Lins
      Jรผrgen Lins

      picture C and D are not visible, can you please re-upload

      Author's profile photo Martin Grob
      Martin Grob
      Blog Post Author

      thanks for the hint the pictures are re-uploaded

      Author's profile photo SRIKANTH GARBHAM
      SRIKANTH GARBHAM

      Hi Martin,

      Good document, but it would be good if you have also mentioned what to be done if the long text is more than 60.

      Srikanth.

      Author's profile photo Martin Grob
      Martin Grob
      Blog Post Author

      Tnx for the hint. Now it has a link to the blog of Eugene

      Author's profile photo Kamal Mehta
      Kamal Mehta

      Hi Martin,

      Thanks. Nice one.

      Could get better if you could add the mechanism to get 'Object' and 'ID' to be passed to FM.

      Regards

      Kamal

      Author's profile photo Martin Grob
      Martin Grob
      Blog Post Author

      Hi

      Thanks for the input I might consider changing it at some point..

      Martin

      Author's profile photo Satendra Mishra
      Satendra Mishra

      Really very helpful document. ๐Ÿ™‚

      Regards,

      Sm

      Author's profile photo Former Member
      Former Member

      Very helpful, thanks for sharing..... ๐Ÿ™‚

      Author's profile photo Former Member
      Former Member

      Nice work...very helpful..

      keep it up the good work !!!

      Author's profile photo Krishna Chaitanya
      Krishna Chaitanya

      Pretty good.  ๐Ÿ™‚

      Author's profile photo Prashanth Konduru
      Prashanth Konduru

      Martin: Simple n usefulll document ... thanks for sharing ๐Ÿ™‚

      Regards

      KP

      Author's profile photo Martin Grob
      Martin Grob
      Blog Post Author

      you're welcome

      Author's profile photo Former Member
      Former Member

      Nice & helpful document martin.

      Thanks for sharing it..

      ๐Ÿ™‚ ๐Ÿ™‚

      Author's profile photo Satendra Mishra
      Satendra Mishra

      Nice information martin ๐Ÿ™‚

      regards.

      SM

      Author's profile photo Manna Das
      Manna Das

      Good to have one more KBA from SCN's stars ๐Ÿ™‚ .

      KR,

      Manna Das