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

REGARDING CODE PROBLEM (VERY URGENT)

Former Member
0 Likes
2,429

HI,

i am making the report in which i have to display the changes made to a material in a purticular month.

my code is when execute it shows a runtime error and says that too many fields in INTO .

HERES IS D CODE:-

TABLES: CDHDR,MSTA,MARA.

DATA: BEGIN OF ITAB OCCURS 0,

MATNR LIKE MARA-MATNR,

ERSDA LIKE MARA-ERSDA,

LAEDA LIKE MARA-LAEDA,

AENAM LIKE MARA-AENAM,

OBJECTCLAS LIKE CDHDR-OBJECTCLAS,

OBJECTID LIKE CDHDR-OBJECTID,

CHANGENR LIKE CDHDR-CHANGENR,

USERNAME LIKE CDHDR-USERNAME,

UDATE LIKE CDHDR-UDATE,

END OF ITAB.

SELECT-OPTIONS: M_DATE FOR MARA-LAEDA.

SELECT AMATNR AERSDA ALAEDA AAENAM BCHANGENR BUSERNAME BUDATE BUTIME

INTO TABLE ITAB FROM MARA AS A INNER JOIN CDHDR AS B ON BUDATE = ALAEDA AND BUSERNAME = AAENAM

WHERE LAEDA IN M_DATE.

  • AND B~OBJECTCLAS = 'MATERIAL'.

LOOP AT ITAB.

WRITE:/ ITAB-MATNR,ITAB-ERSDA,ITAB-LAEDA,ITAB-AENAM.

ENDLOOP.

PLZZ HELP ME IN SOLVING THE PROBLEM AS HELP WILL BE DEFINATELY REWARDED.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,403

Hi,

You have declared below fields in internal table

OBJECTCLAS LIKE CDHDR-OBJECTCLAS,

OBJECTID LIKE CDHDR-OBJECTID,

while selecteing you are not seleting these fields.

So if you don't want to select those fields in select statement Use

"INTO CORRESPONDING FIELDS OF TABLE "

SELECT AMATNR AERSDA ALAEDA AAENAM BCHANGENR BUSERNAME BUDATE BUTIME

INTO COORESPONDING FIELDS OF ITAB

FROM MARA AS A INNER JOIN CDHDR AS B ON BUDATE = ALAEDA AND BUSERNAME = AAENAM

WHERE LAEDA IN M_DATE.

Now it will work.

Don't forget to reward if useful.....

AND B~OBJECTCLAS = 'MATERIAL'

25 REPLIES 25
Read only

Former Member
0 Likes
2,403

AMATNR AERSDA ALAEDA AAENAM BCHANGENR BUSERNAME BUDATE BUTIME

this sequence should be similar to ur internal table other wise

u need to use move corresponding

check it out

Madhavi

Read only

Former Member
0 Likes
2,403

Hi Ric,

You have used UTIME field in your selection.Its not there in your internal table

Read only

Former Member
0 Likes
2,404

Hi,

You have declared below fields in internal table

OBJECTCLAS LIKE CDHDR-OBJECTCLAS,

OBJECTID LIKE CDHDR-OBJECTID,

while selecteing you are not seleting these fields.

So if you don't want to select those fields in select statement Use

"INTO CORRESPONDING FIELDS OF TABLE "

SELECT AMATNR AERSDA ALAEDA AAENAM BCHANGENR BUSERNAME BUDATE BUTIME

INTO COORESPONDING FIELDS OF ITAB

FROM MARA AS A INNER JOIN CDHDR AS B ON BUDATE = ALAEDA AND BUSERNAME = AAENAM

WHERE LAEDA IN M_DATE.

Now it will work.

Don't forget to reward if useful.....

AND B~OBJECTCLAS = 'MATERIAL'

Read only

0 Likes
2,403

Sorry,

Pls. check

You have declared below fields in internal table

OBJECTCLAS LIKE CDHDR-OBJECTCLAS,

OBJECTID LIKE CDHDR-OBJECTID,

while selecteing you are not seleting these fields.

So if you don't want to select those fields in select statement Use

"INTO CORRESPONDING FIELDS OF TABLE "

SELECT AMATNR AERSDA ALAEDA AAENAM BCHANGENR BUSERNAME BUDATE BUTIME

INTO COORESPONDING FIELDS OF ITAB

FROM MARA AS A INNER JOIN CDHDR AS B ON BUDATE = ALAEDA AND BUSERNAME = AAENAM

WHERE LAEDA IN M_DATE.

Now it will work.

Don't forget to reward if useful.....

Read only

0 Likes
2,403

HI,

THANKS TO EVERY ONE , i know where my code was wrong was now i want to display the the changes made in dat material and long withits text ,can any body provide me help as it will be definately rewarded.

Read only

Former Member
0 Likes
2,403

Hi Ric,

You have to use Move Corresponding option in the selwct statement and also, in your ITAB declaration, u didntd declared a filed for UTIME, where as u r selecting the UTIME field also. so u have to include that filed also in your ITAB.

Hope this will help you.

Regards,

Ajith V

Read only

Former Member
0 Likes
2,403

Hi Ric,

use into corresponding fields of .

TABLES: CDHDR,MSTA,MARA.

DATA: BEGIN OF ITAB OCCURS 0,

MATNR LIKE MARA-MATNR,

ERSDA LIKE MARA-ERSDA,

LAEDA LIKE MARA-LAEDA,

AENAM LIKE MARA-AENAM,

OBJECTCLAS LIKE CDHDR-OBJECTCLAS,

OBJECTID LIKE CDHDR-OBJECTID,

CHANGENR LIKE CDHDR-CHANGENR,

USERNAME LIKE CDHDR-USERNAME,

UDATE LIKE CDHDR-UDATE,

END OF ITAB.

SELECT-OPTIONS: M_DATE FOR MARA-LAEDA.

SELECT AMATNR AERSDA ALAEDA AAENAM

BCHANGENR BUSERNAME BUDATE BUTIME

INTO corresponding fields of TABLE ITAB FROM MARA AS A INNER JOIN CDHDR AS B ON BUDATE = ALAEDA AND BUSERNAME = AAENAM

WHERE LAEDA IN M_DATE.

*AND B~OBJECTCLAS = 'MATERIAL'.

LOOP AT ITAB.

WRITE:/ ITAB-MATNR,ITAB-ERSDA,ITAB-LAEDA,ITAB-AENAM.

ENDLOOP.

Read only

Former Member
0 Likes
2,403

Hi,

your selection and internal table are missmatching.So you are getting error.use "into corresponding fields of table" Option.

Try following select statment

SELECT AMATNR AERSDA ALAEDA AAENAM BCHANGENR BUSERNAME BUDATE BUTIME

INTO corresponding fields of TABLE ITAB FROM MARA AS A INNER JOIN CDHDR AS B ON BUDATE = ALAEDA AND BUSERNAME = AAENAM

WHERE LAEDA IN M_DATE.

L.Velu

Read only

Former Member
0 Likes
2,403

Do you find any difference with below code?


tables: mara.

select-options: so_date for mara-laeda.

types: begin of ty_mara,
         matnr type matnr,
         ersda type ersda,
         laeda type laeda,
         aenam type aenam,
       end of ty_mara.

data: i_cdocs type standard table of cdred,
      wa_cdocs type cdred,
      i_mara  type table of ty_mara.

data: r_matnr type range_t_matnr,
      rst_matnr type range_s_matnr.

CALL FUNCTION 'CHANGEDOCUMENT_READ'
  EXPORTING
   DATE_OF_CHANGE                   = so_date-low
    objectclass                      = 'MATERIAL'
   DATE_UNTIL                       = so_date-high
  tables
    editpos                          = i_cdocs
 EXCEPTIONS
   NO_POSITION_FOUND                = 1
   WRONG_ACCESS_TO_ARCHIVE          = 2
   TIME_ZONE_CONVERSION_ERROR       = 3
   OTHERS                           = 4.

delete adjacent duplicates from i_cdocs comparing objectid.

check not i_cdocs[] is initial.

rst_matnr-sign = 'I'.
rst_matnr-option = 'EQ'.
loop at i_cdocs into wa_cdocs.
   rst_matnr-low = wa_cdocs-objectid.
   append rst_matnr to r_matnr.
endloop.

select matnr ersda laeda aenam
       into table i_mara
       from mara
       where matnr in r_matnr.

Display according to the internal tables or moves the values to a final internal table and use to display.

Regards

Eswar

Read only

Former Member
0 Likes
2,403

Hi,

TABLES: CDHDR,MSTA,MARA.

DATA: BEGIN OF ITAB OCCURS 0,

MATNR LIKE MARA-MATNR,

ERSDA LIKE MARA-ERSDA,

LAEDA LIKE MARA-LAEDA,

AENAM LIKE MARA-AENAM,

OBJECTCLAS LIKE CDHDR-OBJECTCLAS,

OBJECTID LIKE CDHDR-OBJECTID,

CHANGENR LIKE CDHDR-CHANGENR,

USERNAME LIKE CDHDR-USERNAME,

UDATE LIKE CDHDR-UDATE,

END OF ITAB.

SELECT-OPTIONS: M_DATE FOR MARA-LAEDA.

The field UTIME is not there in your internal table structure, so

remove that from your select query.

I have made it as bold.

SELECT AMATNR AERSDA ALAEDA AAENAM BOBJECTCLAS BOBJECTID BCHANGENR BUSERNAME BUDATE *"BUTIME*

INTO TABLE ITAB FROM MARA AS A INNER JOIN CDHDR AS B ON BUDATE = ALAEDA AND BUSERNAME = AAENAM

WHERE LAEDA IN M_DATE AND B~OBJECTCLAS = 'MATERIAL'.

LOOP AT ITAB.

WRITE:/ ITAB-MATNR,ITAB-ERSDA,ITAB-LAEDA,ITAB-AENAM.

ENDLOOP.

Read only

0 Likes
2,403

hi,,

dis is my code and when i am executing it is working fine,buti want display the details of the changes made to the material i.ie its old value and new value.

right now my code is dis:-

TABLES: CDHDR,MSTA,MARA.

DATA: BEGIN OF ITAB OCCURS 0,

MATNR LIKE MARA-MATNR,

ERSDA LIKE MARA-ERSDA,

LAEDA LIKE MARA-LAEDA,

AENAM LIKE MARA-AENAM,

CHANGENR LIKE CDHDR-CHANGENR,

USERNAME LIKE CDHDR-USERNAME,

UDATE LIKE CDHDR-UDATE,

UTIME LIKE CDHDR-UTIME,

OBJECTCLAS LIKE CDHDR-OBJECTCLAS,

OBJECTID LIKE CDHDR-OBJECTID,

END OF ITAB.

SELECT-OPTIONS: M_DATE FOR MARA-LAEDA.

SELECT AMATNR AERSDA ALAEDA AAENAM BCHANGENR BUSERNAME BUDATE BUTIME

INTO TABLE ITAB FROM MARA AS A INNER JOIN CDHDR AS B ON BUDATE = ALAEDA AND BUSERNAME = AAENAM

WHERE LAEDA IN M_DATE AND B~OBJECTCLAS = 'MATERIAL'.

LOOP AT ITAB.

WRITE:/ ITAB-MATNR,ITAB-ERSDA,ITAB-LAEDA,ITAB-AENAM,ITAB-UTIME.

ENDLOOP.

Read only

0 Likes
2,403

Try manipulating the coding i have provided above.

Check in debug mode the details available and use accordingly.

You will get all details in I_CDOCS internal table after calling function. Filtering with MM02 transaction can give you the details of the changes.

Regards

Eswar

Edited by: Eswar Rao Boddeti on Jan 22, 2008 1:40 PM

Read only

0 Likes
2,403

Ric,

A small piece of advice for you, with the code you are using now it can cause serious performance issue especially when there is master data upload for the period. So better to go accordingly rather than getting effected at a later stage.

Regards

Eswar

Read only

0 Likes
2,403

hi Eswar Rao Boddeti ,

can u please tell me what should i have to do. actualy i tried to use the TABLE CDHDR and cdpos as i have to display the changes made to the material but when i use to execute the report it was not working ..

can u heklp me put inn dat purpose or should i follow up dis code.

Read only

0 Likes
2,403

Can you execute below code in a temporary program, check output and use accordingly? I hope you can use it from now...


TABLES: mara.

SELECT-OPTIONS: so_date FOR mara-laeda.

CONSTANTS: c_tcode TYPE sytcode VALUE 'MM02'.

TYPES: BEGIN OF ty_mara,
         matnr TYPE matnr,
         ersda TYPE ersda,
         laeda TYPE laeda,
         aenam TYPE aenam,
       END OF ty_mara.
TYPES: BEGIN OF ty_final.
         INCLUDE TYPE ty_mara.
TYPES:   fname TYPE fieldname,
         f_old TYPE cdfldvalo,
         f_new TYPE cdfldvaln,
       END OF ty_final.

DATA: i_cdocs TYPE STANDARD TABLE OF cdred,
      wa_cdocs TYPE cdred,
      i_mara  TYPE TABLE OF ty_mara,
      wa_mara TYPE ty_mara,
      i_final TYPE TABLE OF ty_final,
      wa_final TYPE ty_final.

DATA: r_matnr TYPE range_t_matnr,
      rst_matnr TYPE range_s_matnr.

CALL FUNCTION 'CHANGEDOCUMENT_READ'
  EXPORTING
    date_of_change             = so_date-low
    objectclass                = 'MATERIAL'
    date_until                 = so_date-high
  TABLES
    editpos                    = i_cdocs
  EXCEPTIONS
    no_position_found          = 1
    wrong_access_to_archive    = 2
    time_zone_conversion_error = 3
    OTHERS                     = 4.

DELETE i_cdocs WHERE tcode NE c_tcode.

CHECK NOT i_cdocs[] IS INITIAL.

rst_matnr-sign = 'I'.
rst_matnr-option = 'EQ'.
LOOP AT i_cdocs INTO wa_cdocs.
  rst_matnr-low = wa_cdocs-objectid.
  APPEND rst_matnr TO r_matnr.
ENDLOOP.

SORT r_matnr.
DELETE ADJACENT DUPLICATES FROM r_matnr.

SELECT matnr ersda laeda aenam
       INTO TABLE i_mara
       FROM mara
       WHERE matnr IN r_matnr.

LOOP AT i_cdocs INTO wa_cdocs.
  AT NEW objectid.
    READ TABLE i_mara INTO wa_mara
         WITH KEY matnr = wa_cdocs-objectid.
    MOVE-CORRESPONDING wa_mara TO wa_final.
  ENDAT.
  MOVE-CORRESPONDING wa_cdocs TO wa_final.
  APPEND wa_final TO i_final.
ENDLOOP.

LOOP AT i_final INTO wa_final.
  WRITE:/ wa_final-matnr,
          wa_final-ersda,
          wa_final-laeda,
          wa_final-aenam,
          wa_final-fname,
          wa_final-f_old,
          wa_final-f_new.
ENDLOOP.

Regards

Eswar

Read only

0 Likes
2,403

hi eswar,

i had tried ur code and it is working but one problem is dat i have to display the text also dat these changes are made,as in your code it shows field which had been changed,but iwant to display the texts also.

right now i ahd searched regarding it but the text was not able to find .

should i use CDPOS table.

Read only

0 Likes
2,403

Check field FTEXT of internal table I_CDOCS, you will get the text.

I_CDOCS will contain information from both CDHDR and CDPOS.

Try to check the values in runtime and you get most of the info.

Regards

Eswar

Read only

0 Likes
2,403

yah, eswar is correct.

old value and new value u will get from CDPOS table based on the changer number, field name.

u can test with this FM CHANGEDOCUMENT_READ.

in output f_old contains old value and f_new contains new value

u just run this FM so u can under stand

Madhavi

Read only

0 Likes
2,403

hi madhvi,

the thing is dis CDPOS is a cluster table and it cannot be used in inner join statement so, should i go for aboove code given by ESWAR or should i go with my code and try to use CDPOS statement in other interanal table?

help me as if u will be definately rewarded.

Read only

0 Likes
2,403

hi,

i know dis is showing the values which are old and new ones but i want to display the text also of it.

Read only

0 Likes
2,403

Ric,

You have to put in effort to use the info provided by all friends.

Regards

Eswar

Read only

0 Likes
2,403

ok eswar as u wish.

Read only

Former Member
0 Likes
2,403

hi,

TABLES: CDHDR,MSTA,MARA.

DATA: BEGIN OF ITAB OCCURS 0,

MATNR LIKE MARA-MATNR,

ERSDA LIKE MARA-ERSDA,

LAEDA LIKE MARA-LAEDA,

AENAM LIKE MARA-AENAM,

OBJECTCLAS LIKE CDHDR-OBJECTCLAS,

OBJECTID LIKE CDHDR-OBJECTID,

CHANGENR LIKE CDHDR-CHANGENR,

USERNAME LIKE CDHDR-USERNAME,

UDATE LIKE CDHDR-UDATE,

END OF ITAB.

SELECT-OPTIONS: M_DATE FOR MARA-LAEDA.

SELECT MARAMATNR MARAERSDA MARALAEDA MARAAENAM CDHDRCHANGENR CDHDRUSERNAME CDHDRUDATE CDHDRUTIME

FROM MARA

INNER JOIN CDHDR ON CDHDRUDATE = MARALAEDA AND CDHDRUSERNAME = MARAAENAM into corresponding fields of ITAB

WHERE LAEDA in M_DATE AND CDHDR~OBJECTCLAS = 'MATERIAL'.

LOOP AT ITAB.

WRITE:/ ITAB-MATNR,ITAB-ERSDA,ITAB-LAEDA,ITAB-AENAM.

ENDLOOP.

Read only

Former Member
0 Likes
2,403

Hi,

the code is perfectly alright but in the select query you have to code from fields in the same way as you declared in a internal table.

try this and you will not get the runtime error.

plz reward points if it is useful.

Read only

Former Member
0 Likes
2,403

thanks for all ur help and i had rewarded you according to the help.