02-23-2010 5:27 AM
Hi All,
I have a Z table with 6 fields. The first field is the Plant and is the key field. This field can be matched with the field from selection screen. Now I have 4 character fields which can contain various values. Now I have another field at the end of the table and this field is the one which I will need for further processing.
Now this last field will be selected based on the data for first 5 fields.
This Read is performed in a loop and the data for all the 4 character fields may not be present.
Now my problem is how to build a Read statement for this table where I need to get the value of the Last field based on the values of first 5 fields?
02-23-2010 5:40 AM
do like
read table with key value 1
if sy-subrc is not initial
read table with value2
if sy-subrc is not initial
and so on...
endif.
endif.
02-23-2010 5:36 AM
hi,
i think you use the SY-SUBRC statement after the 4 character field and in the SY-SUBRC you use another READ statement ok
problem is when the 4 charcter field is not found then the SY-SUBRC is 4 and is not going into the If statement, so do not use SY-SUBRC their .
hope this helps
regards
Ritesh
02-23-2010 5:40 AM
do like
read table with key value 1
if sy-subrc is not initial
read table with value2
if sy-subrc is not initial
and so on...
endif.
endif.
02-23-2010 5:49 AM
Hi,
Use
IF you have internal table With header line then use
REad Tablename with key field1 = value1 field2 = value2 field3 = value3 field4 = value4 field5 = value5.
If sy-subrc = 0.
endif.
if you have internal table WithOut header line then use
REad Tablename into workArea with key field1 = value1 field2 = value2 field3 = value3 field4 = value4 field5 = value5.
If sy-subrc = 0.
endif.
regards,
Amit
02-23-2010 6:41 AM
Loop aroud your internal table into work area.
Now the work area will contain all the other fields. You can play around with the other field values and populate the last field and modify your internal table.
End loop.
Not sure why you want to read the internal table here...
Regards,
Ganga
02-23-2010 6:56 AM
DATA i_where(100) OCCURS 0 WITH HEADER LINE.
APPEND u2019vbeln LIKE u2019u2019%1u2019u2019u2019 to i_where.
APPEND u2019matnr LIKE u2019u2019%Mu2019u2019u2019 to i_where.
TABLE lips.
DATA i_lips TYPE TABLE OF lips WITH HEADER LINE.
SELECT * FROM lips INTO TABLE i_lips
WHERE werks = u20191000u2019
AND (i_where)
In a similar way you can use Dynamic Read
Edited by: prince vohra on Feb 23, 2010 7:57 AM
02-26-2010 7:49 AM
Thanks for all the replies.
Thanks Sachin, your post helped me to gain an idea on how to solve my issue.
02-26-2010 10:40 AM
Hi,
As your question is already answered still i want to give one solution.
As you said only first field is key field, so it cannt be blank any time.
also as only one key field so only one record will exist for every plant.
so irrespctive of other four fields, they are blank or having value you can always read this table on your kay field (first).
i hope this will be helpful to you.