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

Appending Problem

former_member251546
Participant
0 Likes
1,980

Hi,

Thank you for helping. ive got a prob whiele assinging the value to itab.


DATA:  itab               TYPE TABLE OF zworksorder.
DATA: lt_pmco TYPE TABLE OF pmco,
        lt_pmco1 TYPE TABLE OF pmco.
  DATA: wa_pmco TYPE pmco.
  Data: lv_GKSTP type RIHAUFK_LIST-GKSTP.
  SELECT objnr wrttp wrt00
  wrt01
  wrt02
  wrt03
  wrt04
  wrt05
  wrt06
  wrt07
  wrt08
  wrt09
  wrt10
  wrt11
  wrt12
  wrt13
  wrt14
  wrt15
  wrt16 FROM pmco INTO CORRESPONDING FIELDS OF TABLE lt_pmco
    FOR ALL ENTRIES IN itab WHERE objnr = itab-objnr.

  LOOP AT lt_pmco INTO wa_pmco WHERE wrttp = '01'.

  COLLECT  wa_pmco INTO lt_pmco1.
  CLEAR:wa_pmco.
  ENDLOOP.

 lOOP AT LT_PMCO1 into wa_pmco.

 lv_gkstp = wa_pmco-WRT00 + wa_pmco-WRT01 + wa_pmco-WRT02 + wa_pmco-WRT03 + wa_pmco-WRT04 + wa_pmco-WRT05 + wa_pmco-WRT06 + wa_pmco-WRT07 + wa_pmco-WRT08
            + wa_pmco-WRT10 + wa_pmco-WRT11 + wa_pmco-WRT12 + wa_pmco-WRT13 + wa_pmco-WRT14 + wa_pmco-wrt15   + wa_pmco-WRT16.
itab-gkstp = lv_gkstp.                   "problem is here i need to assing the lv_gkstp to itab-gkstp
 Endloop.

Plz let me know. how to assing the total value[lv_gkstp to itab-gkstp]

Regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,913

hi,

try this

itab-gkstp = lv_gkstp.

append it_itab.

in place of..

itab-gkstp = lv_gkstp.

hope this helps

regards

Ritesh

18 REPLIES 18
Read only

Former Member
0 Likes
1,914

hi,

try this

itab-gkstp = lv_gkstp.

append it_itab.

in place of..

itab-gkstp = lv_gkstp.

hope this helps

regards

Ritesh

Read only

0 Likes
1,913

hi,

Thank you for reply.

Ive got a total value in lv_gkstp. Now i need to assing this lv_gkstp to Itab-gkstp.

then every order number will get the total planned cost one which is lv_gkstp.


Data: itab table type of zworksorder.
  Data: lv_GKSTP type RIHAUFK_LIST-GKSTP.
 lOOP AT LT_PMCO1 into wa_pmco.

 lv_gkstp = wa_pmco-WRT00 + wa_pmco-WRT01 + wa_pmco-WRT02 + wa_pmco-WRT03 + wa_pmco-WRT04 + wa_pmco-WRT05 + wa_pmco-WRT06 + wa_pmco-WRT07 + wa_pmco-WRT08
            + wa_pmco-WRT10 + wa_pmco-WRT11 + wa_pmco-WRT12 + wa_pmco-WRT13 + wa_pmco-WRT14 + wa_pmco-WRT15 + wa_pmco-WRT16.

 itab-gkstp = lv_gkstp.
 
 Endloop.

while appending the value to itab. its gives the error. bcoz ive declare the itab like Data: itab table type of zworksorder. 
plz let me know how to assing the value to itab. while looping.

Regards

Read only

0 Likes
1,913

Hi,

Do this


LOOP AT LT_PMCO1 into wa_pmco.
  "Calculation of lv_gkstp
  read table itab into wa_itab index sy-tabix where key <field> = wa_pmco-<key_field>.  "If itab is gonna have unique entries, then read the row based on the key field
  move lv_gkstp to wa_itab-gkstp.
  lv_tabix = sy-tabix.
  modify itab from wa_itab index lv_tabix transporting gkstp.
ENDLOOP.

Read only

0 Likes
1,913

You are modifying itab in loop of another internal table without any modify statement

and also the declaration for lv_gkstp is different .

So how do you expect that to work ?

Read only

0 Likes
1,913

Hi,

Thank you. As u told. ive did. but iam getting the error unable to interpret where .possible causes: incorrecting spelling or comma error.



 lOOP AT LT_PMCO1 into wa_pmco.
  
 lv_gkstp = wa_pmco-WRT00 + wa_pmco-WRT01 + wa_pmco-WRT02 + wa_pmco-WRT03 + wa_pmco-WRT04 + wa_pmco-WRT05 + wa_pmco-WRT06 + wa_pmco-WRT07 + wa_pmco-WRT08
            + wa_pmco-WRT10 + wa_pmco-WRT11 + wa_pmco-WRT12 + wa_pmco-WRT13 + wa_pmco-WRT14 + wa_pmco-WRT15 + wa_pmco-WRT16.
 Read table itab into wa index sy-tabix where key objnr = wa_pmco-objnr.   " problem is where condition. 
 move lv_gkstp to wa-gkstp.
 lv_tabix = sy-tabix.
 modify itab from wa  index lv_tabix transporting gkstp.

 Endloop.

Thank you for quick respoce.

Read only

0 Likes
1,913

Hi

While reading from the itab, read either by index or key.

Read only

0 Likes
1,913

hi,

read statement dosen't work with where condition so u have 2 use "with key" in place of where .

rgds/

shivraj

Read only

0 Likes
1,913

Hi,

I made a typo in the read statement.

Sorry for that !!! You could have easily corrected the error if you had checked the documentation of READ


Read table itab into wa index sy-tabix WITH key objnr = wa_pmco-objnr.  "WITH

Read only

0 Likes
1,913

Even ive used with key also

Read table itab into wa index sy-tabix with key objnr = wa_pmco-objnr.

but still gives the error.

Regards

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,913
Read table itab into wa index sy-tabix with key objnr = wa_pmco-objnr.

Can we use both INDEX & WITH KEY addition together in the READ TABLE statement ?

Read only

0 Likes
1,913

hi,

read table itab into wa index sy-tabix.

if sy-subrc = 0 and wa-objnr = wa_pmco-objnr.

ur code.

else.

ur code

endif.

since both index and with key cannot be used together

rgds/

shivraj

Edited by: ShivrajSinha on Mar 17, 2010 10:24 AM

Read only

0 Likes
1,913

Hi,

Thank you..


  Read Table itab index sy-index into wa comparing objnr.
is it right?

Read only

0 Likes
1,913

hi

Thank U



 lOOP AT LT_PMCO1 into wa_pmco.

 lv_gkstp = wa_pmco-WRT00 + wa_pmco-WRT01 + wa_pmco-WRT02 + wa_pmco-WRT03 + wa_pmco-WRT04 + wa_pmco-WRT05 + wa_pmco-WRT06 + wa_pmco-WRT07 + wa_pmco-WRT08
            + wa_pmco-WRT10 + wa_pmco-WRT11 + wa_pmco-WRT12 + wa_pmco-WRT13 + wa_pmco-WRT14 + wa_pmco-WRT15 + wa_pmco-WRT16.
* Read table itab into wa index sy-tabix with key objnr = wa_pmco-objnr.
  Read Table itab index sy-index into wa.
   if sy-subrc = 0 and wa-objnr = wa_pmco-objnr.
    move lv_gkstp to wa-gkstp.
    lv_tabix = sy-tabix.
    modify itab from wa index lv_tabix transporting gkstp.
   else.
     move lv_gkstp to wa-gkstp.
    lv_tabix = sy-tabix.
    modify itab from wa index lv_tabix transporting gkstp.
   endif.
 Endloop.
but its goes to short dump.
Error analysis
    When changing or deleting one or more lines of the internal table
    "\PROGRAM=Z_WORK_ORDER_AGEING_REPORT\DATA=ITAB" or when inserting in the table
     "\PROGRAM=Z_WORK_ORDER_AGEING_REPORT\DATA=ITAB", 0 was used as
    the line index. An index less than or equal to zero is not
    allowed.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,913

Hello Balaji,

Read Table itab index sy-index into wa.
   if sy-subrc = 0 and wa-objnr = wa_pmco-objnr.
     "Your Code
   else.
     move lv_gkstp to wa-gkstp.
    lv_tabix = sy-tabix. " Since the READ statement fails, the value of SY-TABIX = 0
    modify itab from wa index lv_tabix transporting gkstp.
   endif.

but its goes to short dump.

Error analysis

When changing or deleting one or more lines of the internal table

"\PROGRAM=Z_WORK_ORDER_AGEING_REPORT\DATA=ITAB" or when inserting in the table

"\PROGRAM=Z_WORK_ORDER_AGEING_REPORT\DATA=ITAB", 0 was used as

the line index. An index less than or equal to zero is not

allowed.

Please try to analyze the error before blindly posting it in the forum. The error analysis clearly states why the dump has occurred.

BR,

Suhas

Read only

OttoGold
Active Contributor
0 Likes
1,913

How comes you´ve posted over 100 posts and did not get a single point? Keep asking, not answering? Is that ok for you? Otto

Read only

praveen_hannu
Contributor
0 Likes
1,913

Hi

In your case, it seems the both data objects type is not same.

Please try to create your itab as

 data: begin of itab occurs 0.
            include structure zworksorder.
           data: GKSTP type RIHAUFK_LIST-GKSTP,
                    end of itab.


**in the loop you can assign as usual
itab-gsktp = lv_GKSTP.
append itab. 

Check this

Thanks

Praveen

Read only

Former Member
0 Likes
1,913

DATA: itab TYPE TABLE OF zworksorder occurs 0 with header line.

DATA: lt_pmco TYPE TABLE OF pmco,

lt_pmco1 TYPE TABLE OF pmco.

DATA: wa_pmco TYPE pmco.

Data: lv_GKSTP type RIHAUFK_LIST-GKSTP.

SELECT objnr wrttp wrt00

wrt01

wrt02

wrt03

wrt04

wrt05

wrt06

wrt07

wrt08

wrt09

wrt10

wrt11

wrt12

wrt13

wrt14

wrt15

wrt16 FROM pmco INTO CORRESPONDING FIELDS OF TABLE lt_pmco

FOR ALL ENTRIES IN itab WHERE objnr = itab-objnr.

LOOP AT lt_pmco INTO wa_pmco WHERE wrttp = '01'.

COLLECT wa_pmco INTO lt_pmco1.

CLEAR:wa_pmco.

ENDLOOP.

READ TABLE it_pmco1 into wa_pmco with sy-index.

lv_gkstp = wa_pmco-WRT00 + wa_pmco-WRT01 + wa_pmco-WRT02 + wa_pmco-WRT03 + wa_pmco-WRT04 + wa_pmco-WRT05 + wa_pmco-WRT06 + wa_pmco-WRT07 + wa_pmco-WRT08

+ wa_pmco-WRT10 + wa_pmco-WRT11 + wa_pmco-WRT12 + wa_pmco-WRT13 + wa_pmco-WRT14 + wa_pmco-wrt15 + wa_pmco-WRT16.

itab-gkstp = lv_gkstp. "problem is here i need to assing the lv_gkstp to itab-gkstp

append itab.

clear: itab,lv_gkstp.

Read only

ThomasZloch
Active Contributor
0 Likes
1,913

A lot of people tried to help you, but it seems you're not doing any local effort to resolve the problem, instead coming back with every little error you encounter. Try to help yourself first.

Thread locked for this reason.

Thomas