Application Development and Automation 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: 
Read only

help me logic

laxman_sankhla3
Participant
0 Likes
886

i want all matnr , maktx and long description for each and every material no

but in my output in read text functionnal module its passing only one matnr so

only for one material no long text is coming even though another matnr also having material long descrtiption.

check below code

Form Get_Data.

SELECT AMATNR AWERKS B~MAKTX FROM

EKPO AS A

INNER JOIN MAKT AS B ON BMATNR = AMATNR

INTO CORRESPONDING

FIELDS OF TABLE INT_OUT WHERE A~WERKS IN S_WERKS.

sort int_OUT by WERKS.

LOOP AT INT_OUT.

thread-tdname = INT_OUT-MATNR.

ENDLOOP.

thread-tdid = 'BEST'.

thread-tdobject = 'MATERIAL'.

*

CALL FUNCTION 'READ_TEXT'

EXPORTING

  • CLIENT = SY-MANDT

ID = thread-tdid

LANGUAGE = sy-langu

NAME = thread-tdname

OBJECT = thread-tdobject

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

TABLES

LINES = it_tlines.

LOOP AT it_tlines.

read table INT_OUT with key matnr = INT_OUT-MATNR.

IF sy-tabix <> 1.

CLEAR :int_out-matnr, int_out-maktx.

ENDIF.

int_out-tdline = it_tlines-tdline.

delete adjacent duplicates from INT_OUT .

APPEND int_out.

modify INT_OUT index sy-tabix.

ENDLOOP.

suggest me please.

thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
863

Hi,

Check this code.

*----------------------------------------------------------------------*
*----------------------------------------------------------------------*

DATA: l_index LIKE sy-tabix.

SELECT
      a~matnr
      a~werks
      b~maktx FROM ekpo AS a
              INNER JOIN makt AS b
              ON b~matnr = a~matnr
              INTO CORRESPONDING FIELDS OF TABLE int_out
              WHERE a~werks IN s_werks.

SORT int_out BY werks.

LOOP AT int_out.

  l_index = sy-tabix.

  thread-tdname   = int_out-matnr.

  CALL FUNCTION 'READ_TEXT'
       EXPORTING
            client                  = sy-mandt
            id                      = 'BEST'
            language                = sy-langu
            name                    = thread-tdname
            object                  = 'MATERIAL'
       TABLES
            lines                   = it_tlines
       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.
    READ TABLE it_tlines INDEX 1.
    int_out-tdline = it_tlines-tdline.
    MODIFY int_out INDEX l_index.

    CLEAR: it_tlines.
    REFRESH: it_tlines.

  ENDIF.
ENDLOOP.
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*

Regards,

RS

i want all matnr , maktx and long description for each and every material no

but in my output in read text functionnal module its passing only one matnr so

only for one material no long text is coming even though another matnr also having material long descrtiption.

check below code

Form Get_Data.

SELECT AMATNR AWERKS B~MAKTX FROM

EKPO AS A

INNER JOIN MAKT AS B ON BMATNR = AMATNR

INTO CORRESPONDING

FIELDS OF TABLE INT_OUT WHERE A~WERKS IN S_WERKS.

sort int_OUT by WERKS.

LOOP AT INT_OUT.

thread-tdname = INT_OUT-MATNR.

ENDLOOP.

thread-tdid = 'BEST'.

thread-tdobject = 'MATERIAL'.

*

CALL FUNCTION 'READ_TEXT'

EXPORTING

  • CLIENT = SY-MANDT

ID = thread-tdid

LANGUAGE = sy-langu

NAME = thread-tdname

OBJECT = thread-tdobject

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

TABLES

LINES = it_tlines.

LOOP AT it_tlines.

read table INT_OUT with key matnr = INT_OUT-MATNR.

IF sy-tabix <> 1.

CLEAR :int_out-matnr, int_out-maktx.

ENDIF.

int_out-tdline = it_tlines-tdline.

delete adjacent duplicates from INT_OUT .

APPEND int_out.

modify INT_OUT index sy-tabix.

ENDLOOP.

suggest me please.

thanks

7 REPLIES 7
Read only

suresh_datti
Active Contributor
0 Likes
863

Put the read-texxt call inside the loop ie

Form Get_Data.


SELECT A~MATNR A~WERKS B~MAKTX FROM
EKPO AS A
INNER JOIN MAKT AS B ON B~MATNR = A~MATNR
INTO CORRESPONDING
FIELDS OF TABLE INT_OUT WHERE A~WERKS IN S_WERKS.



sort int_OUT by WERKS.

LOOP AT INT_OUT.
thread-tdname = INT_OUT-MATNR.

thread-tdid = 'BEST'.
thread-tdobject = 'MATERIAL'.
*
CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
ID = thread-tdid
LANGUAGE = sy-langu
NAME = thread-tdname
OBJECT = thread-tdobject
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
TABLES
LINES = it_tlines.



LOOP AT it_tlines.

read table INT_OUT with key matnr = INT_OUT-MATNR.


IF sy-tabix <> 1.
CLEAR :int_out-matnr, int_out-maktx.
ENDIF.
int_out-tdline = it_tlines-tdline.

delete adjacent duplicates from INT_OUT .
APPEND int_out.


modify INT_OUT index sy-tabix.
ENDLOOP.
endloop.  "<---

~Suresh

Read only

0 Likes
863

i allready did but giving bug .

thanks

Read only

Former Member
0 Likes
863

Your logic is wrong. rewrite as follows

LOOP AT INT_OUT.

lv_tabix = sy-tabix.

thread-tdname = INT_OUT-MATNR.

thread-tdid = 'BEST'.

thread-tdobject = 'MATERIAL'.

*

CALL FUNCTION 'READ_TEXT'

EXPORTING

  • CLIENT = SY-MANDT

ID = thread-tdid

LANGUAGE = sy-langu

NAME = thread-tdname

OBJECT = thread-tdobject

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

TABLES

LINES = it_tlines.

LOOP AT it_tlines.

concatenate int_out-tdline it_tlines-tdline into int_out-tdline separated by space.

ENDLOOP.

modify INT_OUT index lv_tabix.

clear int_out.

endloop.

Regards,

Ravi

Read only

former_member189629
Active Contributor
0 Likes
863

Hi laxman,

Place the call to "READ_TEXT" within the loop using a perform. In that way, all the matnrs encountered in the loop wil be passed to READ_TEXT and you can retriev eall long texts.

Reward if helpful.

K

Read only

Former Member
0 Likes
863

Form Get_Data.

SELECT AMATNR AWERKS B~MAKTX FROM

EKPO AS A

INNER JOIN MAKT AS B ON BMATNR = AMATNR

INTO CORRESPONDING

FIELDS OF TABLE INT_OUT WHERE A~WERKS IN S_WERKS.

sort int_OUT by WERKS.

LOOP AT INT_OUT.

thread-tdname = INT_OUT-MATNR.

<b>*ENDLOOP. <remove from here.></b>

thread-tdid = 'BEST'.

thread-tdobject = 'MATERIAL'.

*

CALL FUNCTION 'READ_TEXT'

EXPORTING

  • CLIENT = SY-MANDT

ID = thread-tdid

LANGUAGE = sy-langu

NAME = thread-tdname

OBJECT = thread-tdobject

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

TABLES

LINES = it_tlines.

LOOP AT it_tlines.

read table INT_OUT with key matnr = INT_OUT-MATNR.

IF sy-tabix <> 1.

CLEAR :int_out-matnr, int_out-maktx.

ENDIF.

int_out-tdline = it_tlines-tdline.

delete adjacent duplicates from INT_OUT .

APPEND int_out.

modify INT_OUT index sy-tabix.

ENDLOOP.

<b>ENDLOOP. <add here></b>

Read only

Former Member
0 Likes
863

Hi,

Why you are looping IT_LINES.

for each material How many lines of Long Text will come. Single line only. Even if it is 2 lines, read it twice and concatenate and use.

Form Get_Data.

SELECT AMATNR AWERKS B~MAKTX FROM

EKPO AS A

INNER JOIN MAKT AS B ON BMATNR = AMATNR

INTO CORRESPONDING

FIELDS OF TABLE INT_OUT WHERE A~WERKS IN S_WERKS

<b>and b~spras = sy-langu.</b>

sort int_OUT by <b>MATNR</b> WERKS.

delete adjacent duplicates from INT_OUT comparing matnr werks.

LOOP AT INT_OUT.

thread-tdname = INT_OUT-MATNR.

<b>* ENDLOOP.</b>

thread-tdid = 'BEST'.

thread-tdobject = 'MATERIAL'.

*

CALL FUNCTION 'READ_TEXT'

EXPORTING

  • CLIENT = SY-MANDT

ID = thread-tdid

LANGUAGE = sy-langu

NAME = thread-tdname

OBJECT = thread-tdobject

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

TABLES

LINES = it_tlines.

read table it_lines index 1.

if sy-subrc = 0.

int_out-tdline = it_tlines-tdline.

endif.

modify INT_OUT index sy-tabix.

ENDLOOP.

check it will work now.

reward if useful

reagrds,

ANJI

Read only

Former Member
0 Likes
864

Hi,

Check this code.

*----------------------------------------------------------------------*
*----------------------------------------------------------------------*

DATA: l_index LIKE sy-tabix.

SELECT
      a~matnr
      a~werks
      b~maktx FROM ekpo AS a
              INNER JOIN makt AS b
              ON b~matnr = a~matnr
              INTO CORRESPONDING FIELDS OF TABLE int_out
              WHERE a~werks IN s_werks.

SORT int_out BY werks.

LOOP AT int_out.

  l_index = sy-tabix.

  thread-tdname   = int_out-matnr.

  CALL FUNCTION 'READ_TEXT'
       EXPORTING
            client                  = sy-mandt
            id                      = 'BEST'
            language                = sy-langu
            name                    = thread-tdname
            object                  = 'MATERIAL'
       TABLES
            lines                   = it_tlines
       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.
    READ TABLE it_tlines INDEX 1.
    int_out-tdline = it_tlines-tdline.
    MODIFY int_out INDEX l_index.

    CLEAR: it_tlines.
    REFRESH: it_tlines.

  ENDIF.
ENDLOOP.
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*

Regards,

RS