2013 Dec 27 7:03 AM
Hi Folks,
I have internal table with 10 fields , i have to first check what are the fields filled with values eg field1 to field 6 they maintain and from field7 to field10 is '0'.if so i have to check from field1 to field6 (what user maintains in excel) is there any zero values maintained if so i have to raise an error message.
how can i check
1. from which field to field the values are maintained.
2. if so is there any intial values maintained in between the maintained field values.
fld1 fld2 fld3 fld4 fld5 fld6 fld7 fld8 fld9 fld10
10 20 0 0 50 70 0 0 0 0
Thanks,
smriti
2013 Dec 27 7:18 AM
Hi -
1. Create an internal table
2. Populate the internal table from file
3. Check each field of the internal table
Example -1.
1. Step 1
Types : begin of t_itab,
fld1 type i,
fld2 type i,
fld3 type i,
fld4 type i,
fld5 type i,
fld6 type i,
fld7 type i,
fld8 type i,
fld9 type i,
fld10 type i,
end of t_itab.
Data : itab type standard table of t_itab,
w_itab type t_itab.
Step 2
* Use function module like GUI_UPLOAD from file to upload data to t_itab
Step 3.
Loop at itab into w_itab.
if w_itab-fld1 = 0.
MESSAGE E001(ZMESSAGE)
endif.
if w_itab-fld2 = 0.
MESSAGE E002(ZMESSAGE)
ENDIF.
* Repeat the above steps till fld 10
endloop.
* Please create message in a message class
Let us know , if it helps.
Regards,
Atul Mohanty
2013 Dec 27 7:20 AM
Hi Smriti,
As I understand, you want to get the initial field values in between maintained field values. If so,
you can try with looping on internal table in WA and append the initial values with field name to another ITAB.
Compare both ITAB and get your desired result.
All the best.
Regards,
Chandan
2013 Dec 28 6:30 PM
Hi Chandan,
I am not getting what i want as you suggested, could you please elobrate.
my req is
1. upto fld 6 they maintained values in excel so i wanted to check from fld1 to fld6 is there in initial
values( this changes from record to record) so how can i capture the last maintained value for each
record/ row.
2. have to check whether the maintained values i.e., fld1 to fld6 are same like
fld1 = fld2 = fld3 = fld4= fld5= fld6 = same value ( for eg 70)
fld1 fld2 fld3 fld4 fld5 fld6 fld7 fld8 fld9 fld10
10 20 0 0 50 70 0 0 0 0
please provide some input.
Thanks & Regards,
Smriti
2013 Dec 29 6:15 AM
Try using the field symbols :
FIELD-SYMBOLS : <fs> TYPE ANY , <prev> type ANY..
" for each record in excel
Loop at internal_table into workarea.
" 10 times for 10 fields
DO 10 TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE workarea TO <fs>.
IF <fs> IS INITIAL.
WRITE : / <fs> , 'is zero' .
" The last maintained non-zero value is sy-index - 1 ( except for the first record )
EXIT.
ELSE.
IF <prev> IS NOT ASSIGNED. " First Time
ASSIGN <fs> TO <prev>.
ELSE.
" Same or different as previous?
IF <prev> = <fs>.
WRITE : / <fs> , 'is same as previous' .
<prev> = <fs> .
ELSE.
WRITE : / <fs> , 'is different from' , <prev>.
<prev> = <fs> .
ENDIF.
ENDIF.
ENDIF.
ENDDO.
ENDLOOP.
2013 Dec 29 5:22 PM
2013 Dec 29 5:26 PM
you are probably to new to know what a great moderator of the ABAP forum wrote:
Let the forum know that by posting a follow up that includes the solution you found. You may think of the forum just as a place to ask questions but it is really a place where people can exchange ideas. Someone else may come along with the same problem that you had.