ABAP – How to identify invoice text ID

SAPIf you need to read a text out of an invoice, you use standard function module READ_TEXT. But it might be a challenge to identify the correct input parameters for this FM as invoice can contain quite a lot of texts.

The parameters necessary to read text out of an invoice are the following:

  • ID – ID of the text on invoice (will be explained further)
  • NAME – number of the invoice (converted to a variable of type TDOBNAME)
  • LANGUAGE – language in which the text is maintained
  • OBJECT – ‘VBBK’ for invoices

The tricky part is the parameter ID. How to identify the correct text ID?
One possible way is to open the invoice in VF03 and go to header texts

Invoice - Go to header texts

Select the text you want to read to view its contents

Invoice header texts

To display the ID corresponding to their respective texts, press the “Display log” icon.

Invoice texts ID's

Here you can see all the avaiable text ID’s in the invoice. Pick the ID you need (in our case 0014) to read and use it in the READ_TEXT function module call.

  DATA: 
    lv_lang  TYPE sy-langu   VALUE 'D',   " german texts
    lv_vbeln TYPE vbrk-vbeln VALUE '70000419',
    lt_lines TYPE tline_t,
    lv_header_text TYPE char255.

  CALL FUNCTION 'READ_TEXT'
    EXPORTING
*     CLIENT                  = SY-MANDT
      id                      = '0014'
      language                = lv_langu
      name                    = CONV tdobname( lv_vbeln )
      object                  = 'VBBK'
    TABLES
      lines                   = lt_lines
    EXCEPTIONS
      id                      = 1
      language                = 2
      name                    = 3
      not_found               = 4
      object                  = 5
      reference_check         = 6
      wrong_access_to_archive = 7
      OTHERS                  = 8.
  IF sy-subrc = 0.
    LOOP AT lt_lines ASSIGNING FIELD-SYMBOL(<ls_line>).
      AT FIRST.
        lv_header_text = |{ <ls_line>-tdline }|.
        CONTINUE.
      ENDAT.

      lv_header_text = |{ lv_header_text } { <ls_line>-tdline }|.
    ENDLOOP.
  ENDIF.

  WRITE lv_header_text.

If the text is found, the result is returned in the TABLES parameter lines.

Leave a Reply