Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Function Module to hide Style System <H> </> in header text

Former Member
0 Kudos

HI Experts,

I'm currently working on report MM - purchase order header text. My task is to display header text "F01" of MM-purchase order.

After execute the report, under field heading "Header Text", the description of item shows,

STYLE SYSTEM <H>Terms and Conditions:</> This Purchase Order is given to you subject to the terms and conditions.

I just need to display only Terms and Conditions:This Purchase Order is given to you subject to the terms and conditions.

I have searched many FM to hide STYLE SYSTEM <H> </> but no able to get the desired output.

Here is the sample of the coding:

FORM GET_TEXT_HEADER USING TDNAME CHANGING WA_LONGTX."WA_TLINE.

   CALL FUNCTION 'READ_TEXT'

     EXPORTING

       ID                      = 'F01'

       LANGUAGE                = 'E'

       NAME                    = TDNAME

       OBJECT                  = 'EKKO'

     TABLES

       LINES                   = IT_LINES

     EXCEPTIONS

       ID                      = 1

       LANGUAGE                = 2

       NAME                    = 3

       NOT_FOUND               = 4

       OBJECT                  = 5

       REFERENCE_CHECK         = 6

       WRONG_ACCESS_TO_ARCHIVE = 7

       OTHERS                  = 8.

   CLEAR WA_LONGTX.

   LOOP AT IT_LINES.

   CONCATENATE WA_LONGTX IT_LINES-TDLINE INTO WA_LONGTX

   SEPARATED BY SPACE.

   ENDLOOP.

*  MOVE WA_LONGTX TO WA_TLINE.

ENDFORM.                    "GET_TEXT_HEADER

Appreciate for your response, really grateful.

Urgent since user want to use it.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

After asking for my friend's help, she managed to solve it using FM CONVERT_ITF_TO_ASCII given by mr. Manish.

Here is the sample:

FORM GET_TEXT_HEADER USING TDNAME CHANGING WA_LONGTX."WA_TLINE.

   DATA: V_TEMP(9999) TYPE C,

         WA_TEMP LIKE LINE OF IT_CTAB.

   CALL FUNCTION 'READ_TEXT'

     EXPORTING

       ID                      = 'F01'

       LANGUAGE                = 'E'

       NAME                    = TDNAME

       OBJECT                  = 'EKKO'

     TABLES

       LINES                   = IT_LINES

     EXCEPTIONS

       ID                      = 1

       LANGUAGE                = 2

       NAME                    = 3

       NOT_FOUND               = 4

       OBJECT                  = 5

       REFERENCE_CHECK         = 6

       WRONG_ACCESS_TO_ARCHIVE = 7

       OTHERS                  = 8.

   CLEAR WA_LONGTX.

   LOOP AT IT_LINES.

     CALL FUNCTION 'CONVERT_ITF_TO_ASCII'

       IMPORTING

         C_DATATAB         = IT_CTAB

       TABLES

         ITF_LINES         = IT_LINES

       EXCEPTIONS

         INVALID_TABLETYPE = 1

         OTHERS            = 2.

     IF SY-SUBRC <> 0.

       MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

     ENDIF.

     IF IT_LINES CS 'STYLE SYSTEM'.

       REPLACE 'STYLE SYSTEM'  with ' ' into IT_LINES.

     ENDIF.

     LOOP AT IT_CTAB INTO WA_TEMP.

       CONCATENATE V_TEMP WA_TEMP INTO V_TEMP

       SEPARATED BY SPACE.

     ENDLOOP.

     MOVE V_TEMP TO WA_LONGTX.

*    CONCATENATE WA_LONGTX IT_LINES-TDLINE INTO WA_LONGTX

*    SEPARATED BY SPACE.

    ENDLOOP.

*  MOVE WA_LONGTX TO WA_TLINE.

ENDFORM. 

The FM just hide symbol <H> and </> while the word "STYLE SYSTEM" is manually remove using 'IF' condition.

TQ for the response. If anything that anyone think there is much better option, feel free to participate in here. Thanx.

6 REPLIES 6

Former Member
0 Kudos

Since report is custom, you could manually remove the unwanted text from IT_LINES internal table.

Delete <H> and </> only in pairs.

Remove "STYLE SYSTEM".

Loop.

Delete first <H>

Delete last </>

Endloop.

CONDENSE can be done at each removal.

Former Member
0 Kudos

Tq for your response Sir.

But is there any available function module that I can use instead doing it manually.

0 Kudos

After searching a bit, I was able to find the FM.

FM CONVERT_ITF_TO_ASCII will serve your purpose.

Former Member
0 Kudos

After asking for my friend's help, she managed to solve it using FM CONVERT_ITF_TO_ASCII given by mr. Manish.

Here is the sample:

FORM GET_TEXT_HEADER USING TDNAME CHANGING WA_LONGTX."WA_TLINE.

   DATA: V_TEMP(9999) TYPE C,

         WA_TEMP LIKE LINE OF IT_CTAB.

   CALL FUNCTION 'READ_TEXT'

     EXPORTING

       ID                      = 'F01'

       LANGUAGE                = 'E'

       NAME                    = TDNAME

       OBJECT                  = 'EKKO'

     TABLES

       LINES                   = IT_LINES

     EXCEPTIONS

       ID                      = 1

       LANGUAGE                = 2

       NAME                    = 3

       NOT_FOUND               = 4

       OBJECT                  = 5

       REFERENCE_CHECK         = 6

       WRONG_ACCESS_TO_ARCHIVE = 7

       OTHERS                  = 8.

   CLEAR WA_LONGTX.

   LOOP AT IT_LINES.

     CALL FUNCTION 'CONVERT_ITF_TO_ASCII'

       IMPORTING

         C_DATATAB         = IT_CTAB

       TABLES

         ITF_LINES         = IT_LINES

       EXCEPTIONS

         INVALID_TABLETYPE = 1

         OTHERS            = 2.

     IF SY-SUBRC <> 0.

       MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

     ENDIF.

     IF IT_LINES CS 'STYLE SYSTEM'.

       REPLACE 'STYLE SYSTEM'  with ' ' into IT_LINES.

     ENDIF.

     LOOP AT IT_CTAB INTO WA_TEMP.

       CONCATENATE V_TEMP WA_TEMP INTO V_TEMP

       SEPARATED BY SPACE.

     ENDLOOP.

     MOVE V_TEMP TO WA_LONGTX.

*    CONCATENATE WA_LONGTX IT_LINES-TDLINE INTO WA_LONGTX

*    SEPARATED BY SPACE.

    ENDLOOP.

*  MOVE WA_LONGTX TO WA_TLINE.

ENDFORM. 

The FM just hide symbol <H> and </> while the word "STYLE SYSTEM" is manually remove using 'IF' condition.

TQ for the response. If anything that anyone think there is much better option, feel free to participate in here. Thanx.

0 Kudos

FM CONVERT_ITF_TO_ASCII needs to be called only once to convert the internal table.

In your snippet, FM is getting called for every record in IT_LINES, and in every call entire internal table gets converted.

Also, for every record in IT_LINES, you are looping at IT_CTAB. Nested loop is not required.

Code could be something like this:

FORM get_text_header USING tdname CHANGING wa_longtx."WA_TLINE.

  DATA: v_temp(9999) TYPE c,

        wa_temp LIKE LINE OF it_ctab.

* read text into IT_LINES

  CALL FUNCTION 'READ_TEXT'

    EXPORTING

      id                      = 'F01'

      language                = 'E'

      name                    = tdname

      object                  = 'EKKO'

    TABLES

      lines                   = it_lines

    EXCEPTIONS

      id                      = 1

      language                = 2

      name                    = 3

      not_found               = 4

      object                  = 5

      reference_check         = 6

      wrong_access_to_archive = 7

      OTHERS                  = 8.

* convert IT_LINES ITF to ASCII, output stored in IT_CTAB

  CALL FUNCTION 'CONVERT_ITF_TO_ASCII'

    IMPORTING

      c_datatab         = it_ctab

    TABLES

      itf_lines         = it_lines

    EXCEPTIONS

      invalid_tabletype = 1

      OTHERS            = 2.

* remove STYLE SYSTEM, and join lines

  CLEAR wa_longtx.

  LOOP AT it_ctab INTO wa_temp.

    REPLACE 'STYLE SYSTEM' IN wa_temp WITH ' '.

    CONCATENATE v_temp wa_temp INTO v_temp

    SEPARATED BY space.

  ENDLOOP.

  MOVE v_temp TO wa_longtx.

ENDFORM.                    "GET_TEXT_HEADER

Former Member
0 Kudos

I've edited my report by referring to your code, it execute smoothly and get my desired output.

Thank you Mr. Manish for helping.

Really grateful for your response.