Skip to Content
0
Former Member
Jan 04, 2006 at 01:55 AM

after calling FM, how to ensure no redundancy

25 Views

Hi all again,

If some of you recall my earlier thread on the READ_TEXT FM, i have managed to successfully retrieve the PO texts, thanks to you all...

However, i just realized that it works perfectly fine when i test it using 1 example (lets say i pur 1 item number, MATNR) as my selection criteria. However, when i tried it with 2 or more, it still works as the PO Text for all the material numbers appear but they keep on repeating.

As an example, i choose to query 2 material numbers. The first material number will display the PO text for both the first and second material number and it is also the same for the second material number.

Any hints?

I tried doing a CHECK, ON CHANGE OF and even IF...ENDIF, then REFRESH and CLEAR statements to ensure that each material number will display their own respective PO Text instead of all that was queried but still no changes as each material number is displaying all the PO Text instead of their own.

*&---------------------------------------------------------------------*
*&    FORM WRITE_DATA                                                  *
*&---------------------------------------------------------------------*
FORM WRITE_DATA.

  LOOP AT ITAB.

  IF SY-LINNO >= 65.
    NEW-PAGE.
    PERFORM WRITE_HEADER.
  ENDIF.

*--> ALTERNATE COLORS FOR EACH LINE OF OUTPUT
  IF LINE_CHECK = 0.
    FORMAT COLOR COL_NORMAL INTENSIFIED ON.
    LINE_CHECK = 1.
  ELSE.
    FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
    LINE_CHECK = 0.
  ENDIF.

    CLEAR V_PRICE.
    COMPUTE V_PRICE = ( ITAB-NETPR / ITAB-PEINH ).
    NEW-LINE.
    WRITE:   1 '|',   2 ITAB-MATNR,              "MATERIAL CODE
            15 '|',  16 ITAB-MATKL,              "MATERIAL GROUP
            30 '|',  31(40) ITAB-MAKTX,          "DESCRIPTION
            71 '|', " 71 ITAB-MTEXT,             "MATERIAL PO TEXT
           110 '|', " 111 ITAB-PTEXT,            "ITEM TEXT
           150 '|', 157 ITAB-MENGE,              "PURCHASE QUANTITY
           173 '|', 177 V_PRICE DECIMALS 2,      "PURCHASE PRICE
           193 '|', 198 ITAB-BEDAT,              "PURCHASE DATE
           212 '|', 213 ITAB-NAME1,              "PURCHASE VENDOR
           255 '|'.

  PERFORM READ_TXT.

  ENDLOOP.

  WRITE: SY-ULINE.

ENDFORM.

*&---------------------------------------------------------------------*
*&    FORM READ_TXT                                                    *
*&---------------------------------------------------------------------*
FORM READ_TXT.

DATA: L_NAME LIKE THEAD-TDNAME,
      COUNT TYPE I.

LOOP AT ITAB.
  CLEAR: MAT_TXT, MAT_TXT[].

  L_NAME = ITAB-MATNR.

  CALL FUNCTION 'READ_TEXT'
    EXPORTING
      CLIENT                  = SY-MANDT
      ID                      = 'BEST'
      NAME                    = L_NAME
      OBJECT                  = 'MATERIAL'
      LANGUAGE                = SY-LANGU
    TABLES
      LINES                   = MAT_TXT
    EXCEPTIONS
      ID                      = 1
      LANGUAGE                = 2
      NAME                    = 3
      NOT_FOUND               = 4
      OBJECT                  = 5
      REFERENCE_CHECK         = 6
      WRONG_ACCESS_TO_ARCHIVE = 7
      OTHERS                  = 8.

  LOOP AT MAT_TXT.
    MOVE: ITAB-MATNR TO MTXT_TAB-MATNR,
          SY-TABIX TO MTXT_TAB-POSNR,
          MAT_TXT-TDLINE TO MTXT_TAB-LINE.

    APPEND MTXT_TAB.

    WRITE:/72(40) MTXT_TAB-LINE.

  ENDLOOP.

ENDLOOP.

ENDFORM.