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

write statement

Former Member
0 Likes
2,389

Hi Friends,

I have a problem here.

In one report, for example the scenario is like this:

data: itab1 occurs 0,

x like mara-aenam,

end of itab1.

data: itab2 occurs 0,

y like mara-aenam,

end of itab2.

some where in the code i'm writing like this:

write itab2-y to itab1-x.

when i debug the code, i could see the values for <b>itab2-y</b>, but not for the <b>itab1-x</b>.

could you please tell me why it is happening like that?

thnx.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,362

Might be there is a clear statement for <b>itab1</b>

and UR not appending itab1.

26 REPLIES 26
Read only

Former Member
0 Likes
2,363

Might be there is a clear statement for <b>itab1</b>

and UR not appending itab1.

Read only

0 Likes
2,362

You will have to paste all of the code.

Regards,

Rich Heilman

Read only

0 Likes
2,362

Hi Srinivas,

thanks for the reply.

but it is still not showing up the values.

is there anything other could be wrong with that?

thnx

Read only

0 Likes
2,362

Post the code.

Regards,

Rich Heilman

Read only

0 Likes
2,362

Hi Dev,

Can you post the code.

Read only

0 Likes
2,362

friends,

the code is like this:

data: itab1 occurs 0,

matnr like mara-matnr,

appl like a505-kappl,

..................

..................

end of itab1.

data: itab2 occurs 0,

appl like a505-kappl,

...................

...................

end of itab2.

here ther is a form to select the data.

form get_data.

select matnr from mara into corresponding fields of table itab1 where mtart = 'FERT'.

append itab1.

select b~kappl into itab2-appl

from a505 as b

inner join mara as a

on bmatnr = amatnr.

append itab2.

endselect.

write itab2-appl to itab1-appl.

modify itab1.

endform.

Read only

0 Likes
2,362

is there anything to be deleted/added to that code...

plz let me know..

thanks much..

Read only

0 Likes
2,362

I think all you need to do is:


TABLES: mara, a505.

DATA: BEGIN OF itab1 OCCURS 0,
        matnr LIKE mara-matnr,
        appl LIKE a505-kappl,
      END OF itab1.

DATA: BEGIN OF itab2 OCCURS 0,
        matnr LIKE mara-matnr,
        appl LIKE mseg-kappl,
      END OF itab2.

SELECT matnr mblnr
  INTO CORRESPONDING FIELDS OF TABLE itab2
  FROM mseg
    JOIN mara
ON mseg~matnr = mara~matnr.

* Then if you still need to
itab1[] = itab2[].

I'm not entirely sure what you are trying to do. I tried to simplify what I think you are trying to do.

Table A505 doesn't exist in our system, so this code hasn't even passed a syntax check. You'll have to test it thoroughly.

Rob

Message was edited by: Rob Burbank

Read only

0 Likes
2,362

For the modify statement, you need to tell which record you are trying to modify either implied(if done in a loop) or using the where condition or index option. I don't see any of them here. I think what you are looking for is something like this

loop at itab2.

write itab2-appl to itab1-appl.

modify itab1 transporting appl where matnr = itab2-matnr.

endloop.

If there is no link between itab2 and itab1, then I don't think this is possible.

Srinivas

Read only

0 Likes
2,362

Thanks srinivas,

my only concern is i'm not getting the values for itab1.

where as i could see the value for itab2.

plz tell me whether i'm doing it in the right way or not.

thnx

Read only

0 Likes
2,362

Here is your code(actually it will help if you can post your entire FORM code here).


form get_data.

select matnr from mara <u>into corresponding fields of table itab1</u> where mtart = 'FERT'.

<u>append itab1</u>.

select b~kappl into itab2-appl 
from a505 as b
inner join mara as a 
on b~matnr = a~matnr.
append itab2.
endselect.

write itab2-appl to itab1-appl.
modify itab1.

endform.

See the underlined code. If you are using "into table" option, then you don't need the "append itab1". Also, when you do a "into corresponding fields", you should have fields with the same name in your select field list and your internal table.

Srinivas

Read only

0 Likes
2,362

As far as not seeing any values in itab1 is concerned, I don't see anything wrong with your select statement for itab1. Do you actually have FERT material type materials in your system?

Srinivas

Read only

0 Likes
2,362

Srinivas,

I have 2 internal tables:

MATERIAL_DATA.

I_MATERIAL.

the following is the code i have written in FORM.

Plz have a look on that.

form get_awp.

select matnr from mara into corresponding fields of table material_data

where mtart = 'FERT' or mtart = 'HAWA'.

append material_data.

select c~kbetr into i_material-rate

from konp as c

inner join a505 as b

on cknumh = bknumh

inner join mara as a

on bmatnr = amatnr

for all entries IN material_data

where a~matnr = material_data-matnr

and b~kappl = 'V'

and b~kschl = 'ZR10'

and b~vkorg = '1000'

and b~pltyp = '01'

and b~datbi > sy-datum

and b~datab < sy-datum.

append i_material.

endselect.

loop at i_material.

write i_material-rate to material_data-awp.

modify material_data transporting awp.

endloop.

endform. "get_awp

thnx

Read only

0 Likes
2,362
 
form get_awp.

  select matnr from mara 
               into corresponding fields of table material_data
              where mtart = 'FERT'  
                 or mtart = 'HAWA'.

* append material_data. <-- You don't need this

  select b~matnr <-- you have to add this
         c~kbetr into ( i_material-matnr, i_material-rate )
                 from konp as c
           inner join a505 as b
                   on c~knumh = b~knumh
           inner join mara as a
                   on b~matnr = a~matnr
   for all entries IN material_data
                where a~matnr = material_data-matnr
                  and b~kappl = 'V'
                  and b~kschl = 'ZR10'
                  and b~vkorg = '1000'
                  and b~pltyp = '01'
                  and b~datbi > sy-datum
                  and b~datab < sy-datum.
    append i_material.
  endselect.
  loop at i_material.
    write i_material-rate to material_data-awp.
    modify material_data transporting awp 
     where matnr = i_material-matnr.
  endloop.
endform. "get_awp

You are doing the modify of material_data inside the loop of i_material. But you are not specifying which record of material_data you want to modify. That is why it is not working.

Srinivas

Read only

0 Likes
2,362

thank you very much Srinivas,

Now I could see the values are getting displayed for <b>i_material-rate</b> properly for each <b>i_material-matnr</b>. But the problem is still persisting.

I am still unalbe to see the values for <b>material_data-awp</b>. Actually this is the value I have to display in the List. U told that ther shd be a link between <b>i_material</b> and <b>mateial_data</b> internal talbes.

Now there is one field common for both of the Itabs. i.e, matnr.

could u tell me where shd I link them?

thanks....

Read only

0 Likes
2,362

The link is already established in my previous code in which I added the WHERE clause to the MODIFY statement. Put a break-point at the LOOP statement and see if the modify is working.

Read only

0 Likes
2,362

Sreenivas.

I have checked that. Still it is not getting there.

The thing is....when I checked in the debugging, the field values are coming diffrently.

I have declared as following:

<b>i_material-rate like konp-kbetr.

material_data-awp like konp-kbetr.</b>

the DATA TYPE is: CURRENCY

LENGTH is: 11,2

But in debugging it is coming :

Packed number,

length: 6,2.

could this be the reason for that?

but it is coming for both the rate, awp.

then why it is displaying rate values properly in debugging and why not awp.

plz let me know...

thnx much

Read only

0 Likes
2,362

So are you saying that material_data-awp field is getting updated but has some other value?

Replace the <b>WRITE</b> with <b>MOVE</b>.

Read only

0 Likes
2,362

what i meant to say is....in debugging...when i checked for the values for fields: <b>i_material-rate</b> and <b>material_data-awp</b> at run time.....there is a problem coming.

the field contents of <b>i_materail-rate</b> is showing properly only. for eg: 113.57

but when i check for field <b>materail_data-awp</b> there is no value showing up. only 00.00 is showing up.

actually when i move the contents of i_material-rate to material_data-awp...that same value has to be shown up for that field also, right?

but it is not showing up.

when i completely execute the program there is nothing coming up for that <b>"awp"</b> field.

I dont understand why it is happening like that...

plz help me..

Thanx

Read only

0 Likes
2,362

i have replace that "write" with "move" also..still it is not working.

Read only

0 Likes
2,362

Ok, let us check this. In debugging, are you seeing the value of "awp" when you do the move statement?

After the execution of the modify statement, is the internal table material_data updated with the awp value?

Read only

0 Likes
2,362

thnx srinivas

Read only

Former Member
0 Likes
2,362

hi,

In the Debug mode go to tables and enter the name of the itab to view its value instead of typing the values in the fields column.

Or the header might not be appended into the itab.

Read only

govind_seenivasan
Participant
0 Likes
2,362

Hi,

This code is working fine for me.

data: begin of itab1 occurs 0,

x like mara-aenam,

end of itab1.

data: begin of itab2 occurs 0,

y like mara-aenam,

end of itab2.

*some where in the code i'm writing like this:

itab2-y = 'govind'.

append itab2.

clear itab2.

loop at itab2.

write itab2-y to itab1-x.

append itab1.

clear itab1.

endloop.

loop at itab1.

write itab1.

endloop.

Try to change your code like this.

Thanks

Read only

Former Member
0 Likes
2,362

Hi Dev,

U need to check 2 things here.

1. Are you populating the itab2 before writing it to itab1.

2 . Does the Scope of the program allow the data to be written to another table.

its better that u can provide the code .

Regards

Mustameer

Read only

Former Member
0 Likes
2,362

Hi Dev,

When you are moving values to another internal table you should append.

so use append itab1 after you move the value from itab2-y.

Also see that you are not clearing the internal table itab1 in your code.