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

SELECT statement causing error

Former Member
0 Likes
6,532

Hi all, a particular errors keeps on popping up when i try to activate my program. Error message is as follows:


The field "C~NAME1" from the SELECT list is missing in the GROUP BY clause. addition INTO wa or into (g1,...,gn) is required. fields of type "" or "A~MANDT".

Any ideas on what this syntax error message means?

Look at the SELECT statement that is causing the error:


  SELECT A~MATNR A~WERKS MAX( A~EBELN ) MAX( A~EBELP ) A~BUKRS A~MENGE A~NETPR A~PEINH B~LIFNR B~BEDAT C~NAME1
    INTO (WTAB-MATNR, WTAB-WERKS, WTAB-EBELN, WTAB-EBELP, WTAB-BUKRS, WTAB-MENGE, WTAB-NETPR, WTAB-PEINH, WTAB-LIFNR,WTAB-BEDAT, WTAB-NAME1)
    FROM EKPO AS A
      INNER JOIN EKKO AS B
        ON A~EBELN = B~EBELN AND
           A~BUKRS = B~BUKRS
      INNER JOIN LFA1 AS C
        ON B~LIFNR = C~LIFNR
*    FOR ALL ENTRIES IN ITAB
    WHERE A~WERKS = I_WERKS AND
          A~BUKRS = I_BUKRS AND
          B~BSTYP = 'F' AND
          B~SPRAS = 'EN'.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
4,460

Hi again,

1. did ur problem get resolved ?

regards,

amit m.

35 REPLIES 35
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
4,460

I'm not sure what results you will get, but it passes the syntax check.



REPORT ZRICH_0003 .

tables: t001, t001w.

select-options: i_werks for t001w-werks,
                i_bukrs for t001-bukrs.

data: begin of wtab,
      matnr type mara-matnr,
      werks type marc-werks,
      ebeln type ekko-ebeln,
      ebelp type ekpo-ebelp,
      bukrs type t001-bukrs,
      menge type ekpo-menge,
      netpr type ekpo-netpr,
      peinh type ekpo-peinh,
      lifnr type lfa1-lifnr,
      bedat type ekko-bedat,
      name1 type lfa1-name1,
      end of wtab.


  SELECT<b> Single</b> A~MATNR A~WERKS max( A~EBELN ) max( A~EBELP ) A~BUKRS
        A~MENGE A~NETPR A~PEINH B~LIFNR B~bedat C~NAME1
    INTO (WTAB-MATNR, WTAB-WERKS, WTAB-EBELN, WTAB-EBELP, WTAB-BUKRS,
WTAB-MENGE, WTAB-NETPR, WTAB-PEINH, WTAB-LIFNR, WTAB-bedat, WTAB-NAME1)
    FROM EKPO AS A
      INNER JOIN EKKO AS B
        ON A~EBELN = B~EBELN AND
           A~BUKRS = B~BUKRS
      INNER JOIN LFA1 AS C
        ON B~LIFNR = C~LIFNR
*    FOR ALL ENTRIES IN ITAB
    WHERE A~WERKS = I_WERKS AND
          A~BUKRS = I_BUKRS AND
          B~BSTYP = 'F' AND
          B~SPRAS = 'EN'
          <b> group by A~MATNR A~WERKS A~EBELN  A~EBELP  A~BUKRS
                    A~MENGE A~NETPR A~PEINH B~LIFNR B~bedat C~NAME1.</b>

Regard,

Rich Heilman

Read only

Former Member
0 Likes
4,460

Dear Benard,

The problem is that you have used Aggregate Functions of OPEN-Sql (MAX) with Single Line Selection.

You avoid it or try adding GROUP-BY clause.

Regards,

Deva.

Read only

0 Likes
4,460

Thanks Rich, i tried out the codes you posted...it passed the syntax check and managed to activate it. However, no records seems to be queried...even when i leave all the input fields blank before i executed...Maybe it's something wrong with my first SELECT statement? The earlier one i just posted is the second SELECT statement...Have a look:


  SELECT A~MATNR A~MATKL A~MTART A~EXTWG C~WERKS
    INTO CORRESPONDING FIELDS OF ITAB
    FROM MARA AS A
      INNER JOIN MAKT AS B
        ON A~MATNR = B~MATNR
      INNER JOIN MARD AS C
        ON A~MATNR = C~MATNR
    WHERE A~MATNR IN I_MATNR AND
          A~MATKL IN I_MATKL AND
          A~MTART IN I_MTART AND
          A~EXTWG IN I_EXTWG AND
          C~WERKS = I_WERKS.
  SORT ITAB BY MATNR.

It should have worked, right?

Read only

0 Likes
4,460

Just in case, I_BUKRS and I_WERKS are PARAMETERS and the rest are SELECT-OPTIONS:


SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE TEXT-001.
PARAMETERS: I_BUKRS LIKE EKKO-BUKRS,
            I_WERKS LIKE MARD-WERKS.
SELECT-OPTIONS: I_MATNR FOR MARA-MATNR,
                I_MTART FOR MARA-MTART,
                I_MATKL FOR MARA-MATKL,
                I_EXTWG FOR MARA-EXTWG.
SELECTION-SCREEN END OF BLOCK 1.

Read only

0 Likes
4,460

I have to assume that ITAB is an internal table, right? But you are not fetching records into it, You are just fetching 1 record into the header line. You must add the word TABLE before ITAB.




  SELECT A~MATNR A~MATKL A~MTART A~EXTWG C~WERKS
    INTO CORRESPONDING FIELDS OF <b>TABLE</b> ITAB
    FROM MARA AS A
      INNER JOIN MAKT AS B
        ON A~MATNR = B~MATNR
      INNER JOIN MARD AS C
        ON A~MATNR = C~MATNR
    WHERE A~MATNR IN I_MATNR AND
          A~MATKL IN I_MATKL AND
          A~MTART IN I_MTART AND
          A~EXTWG IN I_EXTWG AND
          C~WERKS = I_WERKS.
  SORT ITAB BY MATNR.


Regards,

Rich Heilman

Read only

0 Likes
4,460

Rich, i need your advice on this. During the write statement, only the values retrieved during the first SELECT are part of the output. The values that are supposed to be retrieved during the second SELECT (INTO WTAB) and later MOVE into ITAB do not appear. Any ideas on this?


  LOOP AT WTAB.
    MOVE: WTAB-EBELN TO ITAB-EBELN,
          WTAB-EBELP TO ITAB-EBELP,
          WTAB-BUKRS TO ITAB-BUKRS,
          WTAB-MENGE TO ITAB-MENGE,
          WTAB-NETPR TO ITAB-NETPR,
          WTAB-PEINH TO ITAB-PEINH,
          WTAB-LIFNR TO ITAB-LIFNR,
          WTAB-BEDAT TO ITAB-BEDAT,
          WTAB-NAME1 TO ITAB-NAME1.
    MODIFY ITAB TRANSPORTING EBELN EBELP BUKRS MENGE NETPR PEINH LIFNR
BEDAT NAME1
      WHERE MATNR = WTAB-MATNR AND
            WERKS = WTAB-WERKS.
  ENDLOOP.

Read only

0 Likes
4,460

Hi,

If you have used the following select st.,then you will get only one record during second select st.So if you are looping wtab,it will get get executed only once.

SELECT Single AMATNR AWERKS max( AEBELN ) max( AEBELP ) A~BUKRS

AMENGE ANETPR APEINH BLIFNR Bbedat CNAME1

INTO (WTAB-MATNR, WTAB-WERKS, WTAB-EBELN, WTAB-EBELP, WTAB-BUKRS,

WTAB-MENGE, WTAB-NETPR, WTAB-PEINH, WTAB-LIFNR, WTAB-bedat, WTAB-NAME1)

FROM EKPO AS A

INNER JOIN EKKO AS B

ON AEBELN = BEBELN AND

ABUKRS = BBUKRS

INNER JOIN LFA1 AS C

ON BLIFNR = CLIFNR

  • FOR ALL ENTRIES IN ITAB

WHERE A~WERKS = I_WERKS AND

A~BUKRS = I_BUKRS AND

B~BSTYP = 'F' AND

B~SPRAS = 'EN'

group by AMATNR AWERKS AEBELN AEBELP A~BUKRS

AMENGE ANETPR APEINH BLIFNR Bbedat CNAME1.

So if you want to get all the records,use the table with select st.

<b>SELECT AMATNR AWERKS max( AEBELN ) max( AEBELP ) A~BUKRS

AMENGE ANETPR APEINH BLIFNR Bbedat CNAME1

INTO corresponding fields of table wtab

FROM EKPO AS A

INNER JOIN EKKO AS B

ON AEBELN = BEBELN AND

ABUKRS = BBUKRS

INNER JOIN LFA1 AS C

ON BLIFNR = CLIFNR

WHERE A~WERKS = I_WERKS AND

A~BUKRS = I_BUKRS AND

B~BSTYP = 'F' AND

B~SPRAS = 'EN'

group by AMATNR AWERKS AEBELN AEBELP A~BUKRS

AMENGE ANETPR APEINH BLIFNR Bbedat CNAME1.</b>

Kindly reward points if it helps.

Read only

0 Likes
4,460

it's not working...i'll try using Debugger Mode

Read only

0 Likes
4,460

Hi,

data: begin of wtab occurs 0,

matnr type mara-matnr,

werks type marc-werks,

ebeln type ekko-ebeln,

ebelp type ekpo-ebelp,

bukrs type t001-bukrs,

menge type ekpo-menge,

netpr type ekpo-netpr,

peinh type ekpo-peinh,

lifnr type lfa1-lifnr,

bedat type ekko-bedat,

name1 type lfa1-name1,

end of wtab.

SELECT AMATNR AWERKS max( AEBELN ) max( AEBELP ) A~BUKRS

AMENGE ANETPR APEINH BLIFNR Bbedat CNAME1

INTO corresponding fields of table wtab

FROM EKPO AS A

INNER JOIN EKKO AS B

ON AEBELN = BEBELN AND

ABUKRS = BBUKRS

INNER JOIN LFA1 AS C

ON BLIFNR = CLIFNR

WHERE A~WERKS = I_WERKS AND

A~BUKRS = I_BUKRS AND

B~BSTYP = 'F' AND

B~SPRAS = 'EN'

group by AMATNR AWERKS A~BUKRS

AMENGE ANETPR APEINH BLIFNR Bbedat CNAME1.

If you are not getting values in wtab after this select statement,then try to use for all entries instead of inner join and do the calculations using loop.

Read only

0 Likes
4,460

i managed to solve it using another way...the thing is now that when i key in values in the search criteria for I_BUKRS, I_WERKS, I_MATKL, I_MTART or I_EXTWG, no records are returned. If i key in a value in I_WERKS, all records of that Plant are returned (so i know there is nothing wrong with it) and if i also key in a value in I_MATNR, the exact material (of that material number) from that plant will appear?

Should it be when i key in a value in only 1 selection criteria, all records that fulfill that criteria appear?

Let's say i key in 'ELE' value in Material Group (I_MATKL), it should retrieve and output all material of that Material Group, but it doesn't...something wrong with my SELECT statements again?

Read only

0 Likes
4,460

Hi Bernard,

I may be repeating , but make sure :

1. For parameters : the query should be =

For select-options : the query should be IN

2. Can u paste the code for selection screen

and ur sql also.

Regards,

Amit M.

Read only

0 Likes
4,460

sure, here's the update codes:


*&---------------------------------------------------------------------*
*&    SELECTION-SCREEN                                                 *
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE TEXT-001.
PARAMETERS: I_BUKRS LIKE EKKO-BUKRS,
            I_WERKS LIKE MARD-WERKS.
SELECT-OPTIONS: I_MATNR FOR MARA-MATNR,
                I_MTART FOR MARA-MTART,
                I_MATKL FOR MARA-MATKL,
                I_EXTWG FOR MARA-EXTWG.
SELECTION-SCREEN END OF BLOCK 1.

*&---------------------------------------------------------------------*
*&    FORM SELECT_DATA                                                 *
*&---------------------------------------------------------------------*
FORM SELECT_DATA.

  SELECT A~MATNR A~MATKL A~MTART A~EXTWG C~WERKS
    INTO TABLE ITAB
    FROM MARA AS A
      INNER JOIN MAKT AS B
        ON A~MATNR = B~MATNR AND
           B~SPRAS = 'EN'
      INNER JOIN MARD AS C
        ON A~MATNR = C~MATNR
    WHERE A~MATNR IN I_MATNR AND
          A~MATKL IN I_MATKL AND
          A~MTART IN I_MTART AND
          A~EXTWG IN I_EXTWG AND
          C~WERKS = I_WERKS.
  SORT ITAB BY MATNR.

*  CHECK ITAB-MATNR IN I_MATNR.
*  CHECK ITAB-MATKL IN I_MATKL.
*  CHECK ITAB-MTART IN I_MTART.
*  CHECK ITAB-EXTWG IN I_EXTWG.
*  CHECK ITAB-WERKS = I_WERKS.

  CHECK NOT ITAB[] IS INITIAL.

  SELECT A~MATNR A~WERKS MAX( A~EBELN ) MAX( A~EBELP ) A~BUKRS
A~MENGE A~NETPR A~PEINH B~LIFNR B~BEDAT C~NAME1
  INTO CORRESPONDING FIELDS OF TABLE WTAB
*    INTO (WTAB-MATNR, WTAB-WERKS, WTAB-EBELN, WTAB-EBELP, WTAB-BUKRS,
*WTAB-MENGE, WTAB-NETPR, WTAB-PEINH, WTAB-LIFNR,WTAB-BEDAT, WTAB-NAME1)
    FROM EKPO AS A
      INNER JOIN EKKO AS B
        ON A~EBELN = B~EBELN AND
           A~BUKRS = B~BUKRS AND
           B~BSTYP = 'F'
      INNER JOIN LFA1 AS C
        ON B~LIFNR = C~LIFNR
*    FOR ALL ENTRIES IN ITAB
    WHERE A~MATNR IN I_MATNR AND
          A~MATKL IN I_MATKL AND
          A~WERKS = I_WERKS AND
          A~BUKRS = I_BUKRS AND
          A~MTART IN I_MTART AND
          A~LOEKZ = ' '
    GROUP BY A~MATNR A~WERKS A~EBELN A~EBELP A~BUKRS A~MENGE A~NETPR
A~PEINH B~LIFNR B~BEDAT C~NAME1.

*CHECK ITAB-BUKRS = I_BUKRS.
*CHECK EKKO-BSTYP = 'F'.
*CHECK EKKO-SPRAS = 'EN'.

  LOOP AT WTAB.
    MOVE: WTAB-EBELN TO ITAB-EBELN,
          WTAB-EBELP TO ITAB-EBELP,
          WTAB-BUKRS TO ITAB-BUKRS,
          WTAB-MENGE TO ITAB-MENGE,
          WTAB-NETPR TO ITAB-NETPR,
          WTAB-PEINH TO ITAB-PEINH,
          WTAB-LIFNR TO ITAB-LIFNR,
          WTAB-BEDAT TO ITAB-BEDAT,
          WTAB-NAME1 TO ITAB-NAME1.
    MODIFY ITAB TRANSPORTING EBELN EBELP BUKRS MENGE NETPR PEINH LIFNR
BEDAT NAME1
      WHERE MATNR = WTAB-MATNR.
*      WERKS = WTAB-WERKS.
  ENDLOOP.

  LINE_CHECK = 0.

ENDFORM.

Read only

Former Member
0 Likes
4,460

Hi Bernard,

1. The parameters I_BUKRS and I_WERKS

should always have some value (OBLIGATORY)

2. Bcos we have used = in sql.

If they are blank, no values will be returned.

3. I tried ur code (till the first SELECT)

at my end, it works fantastic.

4. try this code (just copy paste)

and see the ITAB after select statement at break-point.

5. REPORT abc.

*&----


**& SELECTION-SCREEN

**&----


TABLES : mara.

DATA : itab LIKE TABLE OF mara WITH HEADER LINE.

SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE text-001.PARAMETERS:

i_bukrs LIKE ekko-bukrs obligatory,

i_werks LIKE mard-werks obligatory.

SELECT-OPTIONS: i_matnr FOR mara-matnr,

i_mtart FOR mara-mtart,

i_matkl FOR mara-matkl, i_extwg FOR mara-extwg.

SELECTION-SCREEN END OF BLOCK 1.

START-OF-SELECTION.

PERFORM select_data.

*&----


*

*& FORM SELECT_DATA *

&----


FORM select_data.

select *

into corresponding fields of table itab

from mara as a

inner join makt as b

on amatnr = bmatnr and

b~spras = 'EN'

inner join mard as c

on amatnr = cmatnr

where a~matnr in i_matnr and

a~matkl in i_matkl and

a~mtart in i_mtart and

a~extwg in i_extwg and

c~werks = i_werks.

break-point.

endform.

I hope it helps.

Regards,

Amit M.

Read only

0 Likes
4,460

do i need to paste it over the 1st and 2nd select?

Read only

0 Likes
4,460

Hi again,

1. For trial purpose,

don't overwrite any of your code.

2. Just make another program Y/z.

and copy my code

to see that it works fantastic,

( It is your code only,

i have made only some variable declaration)

regards,

amit m.

Read only

Former Member
0 Likes
4,460

Hi again,

1. did ur problem get resolved ?

regards,

amit m.

Read only

Former Member
0 Likes
4,461

Hi again,

1. did ur problem get resolved ?

regards,

amit m.

Read only

0 Likes
4,460

Sorry abt the late reply...Christmas and was busy with other functional stuff...

Well, i did try your solution and it works...but i'm manage to also find a solution to it on my own....

However, right now, i noticed another problem with the second SELECT statement for WTAB.


  SELECT A~MATNR A~MATKL A~WERKS MAX( A~EBELN ) MAX( A~EBELP ) A~BUKRS
A~MENGE A~NETPR A~PEINH A~MTART B~LIFNR B~BEDAT C~NAME1
  INTO CORRESPONDING FIELDS OF TABLE WTAB
*    INTO (WTAB-MATNR, WTAB-WERKS, WTAB-EBELN, WTAB-EBELP, WTAB-BUKRS,
*WTAB-MENGE, WTAB-NETPR, WTAB-PEINH, WTAB-LIFNR,WTAB-BEDAT, WTAB-NAME1)
    FROM EKPO AS A
      INNER JOIN EKKO AS B
        ON A~EBELN = B~EBELN AND
           A~BUKRS = B~BUKRS AND
           B~BSTYP = 'F'
      INNER JOIN LFA1 AS C
        ON B~LIFNR = C~LIFNR
    WHERE A~MATNR IN I_MATNR AND
          A~MATKL IN I_MATKL AND
          A~WERKS = I_WERKS AND
          A~BUKRS = I_BUKRS AND
          A~MTART IN I_MTART AND
          A~LOEKZ = ' '
    GROUP BY A~MATNR A~MATKL A~WERKS A~EBELN A~EBELP A~BUKRS A~MENGE
A~NETPR A~PEINH A~MTART B~LIFNR B~BEDAT C~NAME1.

For some reason, it is not extracting the values for EBELN and EBELP...when i went through debug mode, i noticed that in each record, EBELN would appear as a blank and EBELP would appear in zeros...

Any ideas?

Read only

0 Likes
4,460

What is your definition of WTAB? Looks like you are selecting MATNR, <b><u>MATKL</u></b>, WERKS.... from the tables, but your WTAB field for MATKL might be missing.

The fields you select should be there in your WTAB with the same name if you are using INTO CORRESPONDING FIELDS OF option.

If you are using INTO (fld1, fld2, fld3...) then the order of the fields you select should match the order of the fields you listed in the INTO list. Here the names need not match but they should have the same types.

Srinivas

Read only

0 Likes
4,460

The definition of WTAB is as follows:

[code

DATA: BEGIN OF WTAB OCCURS 0,

MATNR TYPE EKPO-MATNR, "Material Number

MATKL TYPE EKPO-MATKL, "Material Group

WERKS TYPE EKPO-WERKS, "Plant

EBELN TYPE EKPO-EBELN, "Purchasing Document Number

EBELP TYPE EKPO-EBELP, "Item Number of Purchasing Document

BUKRS TYPE EKPO-BUKRS, "Company Code

MENGE TYPE EKPO-MENGE, "Purchase order quantity

NETPR TYPE EKPO-NETPR, "Net price in purchasing document

PEINH TYPE EKPO-PEINH, "Price unit

MTART TYPE EKPO-MTART, "Material Type

LIFNR TYPE EKKO-LIFNR, "Account Number of the Vendor

BEDAT TYPE EKKO-BEDAT, "Purchasing Document Date

NAME1 TYPE LFA1-NAME1, "Name 1

END OF WTAB.

[/code]

But in my MOVE statements, i did not move MATKL as i do not want it to overwrite the one that was extracted by the first loop (ITAB)

Read only

0 Likes
4,460

Hi bernard,

1 I just checked its happening because of

MAX

2. This MAX is not working

with the statement

INTO CORRESPONDING FIELDS OF TABLE

3. When MAX is used,

the field name returned from database

changes.

4. Hence do not use

INTO CORRESPONDING FIELDS OF TABLE

5. Just use

INTO TABLE WTAB.

(and declare wtab in the same sequence

in which the fields are fetched in sql query.

6. To demonstarte my point, try this code

(just copy paste in a new z program)

REPORT abc.

DATA : BEGIN OF wtab OCCURS 0,

ebeln LIKE ekpo-ebeln,

ebelp LIKE ekpo-ebelp,

END OF wtab.

SELECT ebeln MAX( ebelp )

FROM ekpo

INTO TABLE wtab

GROUP BY ebeln.

BREAK-POINT.

7. Here in the code if we use

INTO CORRESPONDGIN, THEN IT WON'T WORK.

TRY IT FOR YOURSELF.

I hope it helps.

regards,

amit m.

Read only

0 Likes
4,460

Thanks, it worked

Read only

0 Likes
4,460

I've got another thing to ask. Ask you all know, i am suppose to complete (or ammend) the program that i am doing now. Look at parts of the original coding that i have yet to make changes to, i would like to know what is it suppose to do and output. Perhaps you guys could explain it better than my consultant:


TYPES: BEGIN OF TYP_MATTXT,
         MATNR LIKE MARA-MATNR,  "Material Number
         CTRT TYPE I,
         MAT_TXT(80) TYPE C,
         PO_TXT(80) TYPE C,
       END OF TYP_MATTXT.

DATA: MATTXT TYPE TYP_MATTXT OCCURS 0 WITH HEADER LINE.

DATA: WA_STXH TYPE STXH,
      TXT LIKE TLINE OCCURS 0 WITH HEADER LINE,
      TXT_KEY LIKE STXH-TDNAME.  "Name

*&---------------------------------------------------------------------*
*&    FORM SELECT_DATA                                                 *
*&---------------------------------------------------------------------*
FORM SELECT_DATA.

  SELECT A~MATNR A~MATKL B~MAKTX A~MTART A~EXTWG C~WERKS
    INTO CORRESPONDING FIELDS OF TABLE ITAB
    FROM MARA AS A
      INNER JOIN MAKT AS B
        ON A~MATNR = B~MATNR AND
           B~SPRAS = 'EN'
      INNER JOIN MARD AS C
        ON A~MATNR = C~MATNR
    WHERE A~MATNR IN I_MATNR AND
          A~MATKL IN I_MATKL AND
          A~MTART IN I_MTART AND
          A~EXTWG IN I_EXTWG AND
          C~WERKS = I_WERKS.

  SORT ITAB BY MATNR MATKL MTART EXTWG WERKS MAKTX.

  CHECK NOT ITAB[] IS INITIAL.

  SELECT A~MATNR A~MATKL A~WERKS MAX( A~EBELN ) MAX( A~EBELP ) A~BUKRS
A~MENGE A~NETPR A~PEINH A~MTART B~LIFNR B~BEDAT C~NAME1
  INTO TABLE WTAB
*    INTO (WTAB-MATNR, WTAB-WERKS, WTAB-EBELN, WTAB-EBELP, WTAB-BUKRS,
*WTAB-MENGE, WTAB-NETPR, WTAB-PEINH, WTAB-LIFNR,WTAB-BEDAT, WTAB-NAME1)
    FROM EKPO AS A
      INNER JOIN EKKO AS B
        ON A~EBELN = B~EBELN AND
           A~BUKRS = B~BUKRS AND
           B~BSTYP = 'F'
      INNER JOIN LFA1 AS C
        ON B~LIFNR = C~LIFNR
    WHERE A~MATNR IN I_MATNR AND
          A~MATKL IN I_MATKL AND
          A~WERKS = I_WERKS AND
          A~BUKRS = I_BUKRS AND
          A~MTART IN I_MTART AND
          A~LOEKZ = ' '
    GROUP BY A~MATNR A~MATKL A~WERKS A~EBELN A~EBELP A~BUKRS A~MENGE
A~NETPR A~PEINH A~MTART B~LIFNR B~BEDAT C~NAME1.

  SORT WTAB BY MATNR MATKL MTART WERKS EBELN EBELP MENGE NETPR PEINH
LIFNR BEDAT NAME1.

  LOOP AT WTAB.
    MOVE: WTAB-EBELN TO ITAB-EBELN,
          WTAB-EBELP TO ITAB-EBELP,
          WTAB-BUKRS TO ITAB-BUKRS,
          WTAB-MENGE TO ITAB-MENGE,
          WTAB-NETPR TO ITAB-NETPR,
          WTAB-PEINH TO ITAB-PEINH,
*          WTAB-MTART TO ITAB-MTART,
          WTAB-LIFNR TO ITAB-LIFNR,
          WTAB-BEDAT TO ITAB-BEDAT,
          WTAB-NAME1 TO ITAB-NAME1.

   MOVE ITAB-MATNR TO TXT_KEY.

   PERFORM READ_TXT USING 'BEST' TXT_KEY 'MATERIAL'.

   CONCATENATE ITAB-EBELN ITAB-EBELP INTO TXT_KEY.

   PERFORM READ_TXT USING 'F01' TXT_KEY 'EKPO'.

    MODIFY ITAB TRANSPORTING EBELN EBELP BUKRS MENGE NETPR PEINH LIFNR
BEDAT NAME1
      WHERE MATNR = WTAB-MATNR.
  ENDLOOP.

  SORT ITAB BY MATNR MATKL MTART.

  DELETE ADJACENT DUPLICATES FROM ITAB COMPARING ALL FIELDS.

  LINE_CHECK = 0.

ENDFORM.

*&---------------------------------------------------------------------*
*&    FORM READ_TXT                                                    *
*&---------------------------------------------------------------------*
FORM READ_TXT USING ID XNAME OBJ.

DATA: CTR TYPE I,
      PO_CTR TYPE I.

CLEAR: TXT.

  SELECT SINGLE * FROM STXH CLIENT SPECIFIED
  INTO WA_STXH
  WHERE MANDT = SY-MANDT AND
        TDOBJECT = OBJ AND
        TDNAME = XNAME AND
        TDID = ID AND
        TDSPRAS  = SY-LANGU.

  IF SY-SUBRC = 0.
    REFRESH TXT.
    CTR = 1.
    CALL FUNCTION 'READ_TEXT'
         EXPORTING
              CLIENT   = SY-MANDT
              ID       = ID
              NAME     = XNAME
              OBJECT   = OBJ
              LANGUAGE = SY-LANGU
         TABLES
              LINES    = TXT.

    LOOP AT TXT.
      IF ID = 'BEST'.
        MOVE XNAME TO MATTXT-MATNR.
        MOVE CTR TO MATTXT-CTRT.
        MOVE TXT-TDLINE TO MATTXT-MAT_TXT.
        APPEND MATTXT.
      ELSEIF ID = 'F01'.
        READ TABLE MATTXT WITH KEY MATNR = ITAB-MATNR CTRT = CTR.
        IF SY-SUBRC = 0.
          MOVE TXT-TDLINE TO MATTXT-PO_TXT.
          MODIFY MATTXT TRANSPORTING PO_TXT
          WHERE MATNR = ITAB-MATNR.
        ELSE.
          MOVE ITAB-MATNR TO MATTXT-MATNR.
          MOVE CTR TO MATTXT-CTRT.
          MOVE TXT-TDLINE TO MATTXT-PO_TXT.
          APPEND MATTXT.
        ENDIF.
      ENDIF.
      CTR = CTR + 1.
    ENDLOOP.
  ENDIF.

ENDFORM.

Read only

0 Likes
4,460

FYI, its the CALL FUNCTION i am asking abt...

Read only

0 Likes
4,460

The call function is reading specific material texts like purchasing texts and so on.

These are texts used on PO, Sales documents etc... stored in a text table and not in MAKT.

Enjoy

Read only

0 Likes
4,460

So does it mean that it will read the "text" area of POs? As in Item Text, Material PO Text, Item Note and the like in the PO? So if no text was actually written in the text area of the PO, it would appear as blank when extracted?

Read only

0 Likes
4,460

Not quite.

Some texts are chosen at PO creation from the Text Repository. These may be item driven (material nbr).

Now these texts will exist whether you have a PO or not.

It is just configured to be pulled at PO creation.

The text function will allow you to read those texts.

Depending on whether you are looking for the text on the PO or the text being pulled into the PO at creation, the keys will differ. But the texts if they are present will be returned from the repository by that function.

Enjoy

Read only

0 Likes
4,460

Ok...thats very very technical 😛

So now i am suppose to retrive the Material PO Text and Item Text...what would i need to change in the call function?

For some reason...i am only able to retrieve and display some text for the Material PO Text, but what appeared doesn't look exactly like the one that appear in ME22N, only a jumble of words that don't make sense...a description of the item should have appeared instead...

Read only

0 Likes
4,460

Well you need to ask your business team how they configured ME22N. Each item text type has a specific text identifier.

Then you need to play around some with the function using the key fields. Hint concatenate ebeln and ebelp in the key.

This should allow you to retrieve the specific text for a specific PO.

Enjoy

Read only

0 Likes
4,460

Thanks for the tip...i went into SE37 to see what the function call is all abt...i'm abit confused on a particular thing...the importing parameters NAME and OBJECT is explained as "Name of text to be read" and "Object of text to be read"...don't they mean the same thing? If they are different, whats the difference?

Read only

0 Likes
4,460

No replies??

Anyway, i've got another question to ask. I just noticed that some of the descriptions in the Description, Material PO Text and Item Text columns exceed more than 40 characters, therefore when the report is generated, the width of the report is not wide enough.

I went back to the consultant and i was told to use ALVs...what are ALVs and do i have to use a particular transaction code to do it?

Read only

0 Likes
4,460

Hmmm...i'm going to close this thread now...since the question that i am asking now is no longer related to the original threat i opened...i'll open another thread with a proper title

Read only

0 Likes
4,460

ALV is ABAP List Viewer. This is functionality provided by SAP. There are two ways of coding an ALV for your report. You can use the function module way or the class/method way. Since you are new to ABAP, I will not confuse you with ABAP OO yet. Here is a sample program showing you how to code an ALV grid using the function module.



report zrich_0004
       no standard page heading.

type-pools slis.

data: fieldcat type slis_t_fieldcat_alv.

data: begin of imara occurs 0,
      matnr type mara-matnr,
      maktx type makt-maktx,
      end of imara.

* Selection Screen
selection-screen begin of block b1 with frame title text-001 .
select-options: s_matnr for imara-matnr .
selection-screen end of block b1.

start-of-selection.

  perform get_data.
  perform write_report.


************************************************************************
*  Get_Data
************************************************************************
form get_data.

  select  mara~matnr makt~maktx
            into corresponding fields of table imara
              from mara
               inner join makt
                 on mara~matnr = makt~matnr
                    where mara~matnr in s_matnr
                      and makt~spras = sy-langu.

endform.

************************************************************************
*  WRITE_REPORT
************************************************************************
form write_report.

  perform build_field_catalog.

* CALL ABAP LIST VIEWER (ALV)
  call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            it_fieldcat = fieldcat
       tables
            t_outtab    = imara.

endform.

************************************************************************
* BUILD_FIELD_CATALOG
************************************************************************
form build_field_catalog.

  data: fc_tmp type slis_t_fieldcat_alv with header line.
  clear: fieldcat. refresh: fieldcat.

  clear: fc_tmp.
  fc_tmp-reptext_ddic    = 'Material Number'.
  fc_tmp-fieldname  = 'MATNR'.
  fc_tmp-tabname   = 'IMARA'.
  fc_tmp-outputlen  = '18'.
  fc_tmp-col_pos    = 2.
  append fc_tmp to fieldcat.


  clear: fc_tmp.
  fc_tmp-reptext_ddic    = 'Material'.
  fc_tmp-fieldname  = 'MAKTX'.
  fc_tmp-tabname   = 'IMARA'.
  fc_tmp-outputlen  = '40'.
  fc_tmp-col_pos    = 3.
  append fc_tmp to fieldcat.

endform.

Regards,

Rich Heilman

Read only

0 Likes
4,460

Hi Bernard,

For alv stuff visit this link,

http://sapdevelopment.co.uk/alvhome

even if you go to package SLIS in se80 you can see lot of alv programs.

regards

vijay

Read only

Former Member
0 Likes
4,460

Hi,

Pls close this thread a post a new thread.

regards,

amit m.