‎2006 Jul 26 8:52 PM
I need some help on the following program. when I run this program in debug mode and click on the "it_uct200g" in the select statement, I see the data that was selected. the problem is that the if statement is not working noe is the last write statement. when you click on these fields there is nothing data be displayed. I am not sure why I would see data when I click on the table in the select statement and not when I clicked on the separate fields within the table.
REPORT ZTEST3.
TABLES:
UCT200G.
TYPES: BEGIN OF ty_uct200g,
siselid TYPE uct200g-siselid,
fieldname TYPE uct200g-fieldname,
sisel TYPE uct200g-sisel,
END OF ty_uct200g.
data: it_uct200g TYPE STANDARD TABLE OF ty_uct200g with header line.
*
----
*START-OF-SELECTION *
----
START-OF-SELECTION.
select siselid fieldname sisel
FROM UCT200G INTO TABLE it_uct200g
WHERE fieldname = '/BIC/ZVTYPE1 '
AND sisel = 'PLANNING '.
write: / 'process successful return code = ', sy-subrc.
if it_uct200g-sisel = 'PLANNING '.
write: / ' the field is filled'.
endif.
write: / '****', it_uct200g-siselid,'',it_uct200g-fieldname,'*',it_uct200g-sisel.
‎2006 Jul 27 9:00 PM
I am having problems setting up the program to use work areas. I have included part of the program. would it be possible for someone to fix what I have coded to have the work aresa properly defined.
thanks in advance
REPORT ZTEST3.
TYPES: BEGIN OF ty_uct200g,
siselid TYPE uct200g-siselid,
fieldname TYPE uct200g-fieldname,
sisel TYPE uct200g-sisel,
END OF ty_uct200g.
data: it_uct200g type ty_uct200g.
data: wa_200g type ty_uct200g.
----
*START-OF-SELECTION *
----
START-OF-SELECTION.
select siselid fieldname sisel
FROM UCT200G INTO wa_200g
WHERE fieldname = '/BIC/ZVTYPE1 '
AND sisel = 'PLANNING '.
write: / 'process successful return code = ', sy-subrc.
loop at ty_uct200g into wa_200g.
write: / 'uct200g****', wa_200g-siselid,'',wa_200g-fieldname,'*',wa_200g-sisel.
endloop.
*
‎2006 Jul 26 8:58 PM
That's probably because you are looking at the header line. You may want to loop at the table and then write, or read the table with an index of 1.
‎2006 Jul 26 9:09 PM
ur write statement is not in loop so it checks the last record present in headerline ... if the last record is not the record in if statement then u dont fetch record.
or write select statement like
select fields from dbtable into itab where ......
if field = 'PLANNING'.
write: / 'UR STATEMENT'.
endselect.
or as rich told put it in loop at itab.
‎2006 Jul 26 8:59 PM
The reason is that you need to read the table, or loop at it to put something in the header line of the table.
REPORT ZTEST3.
TABLES:
UCT200G.
TYPES: BEGIN OF ty_uct200g,
siselid TYPE uct200g-siselid,
fieldname TYPE uct200g-fieldname,
sisel TYPE uct200g-sisel,
END OF ty_uct200g.
data: it_uct200g TYPE STANDARD TABLE OF ty_uct200g with header line.
*
*-------------------------------------------------------*
*START-OF-SELECTION *
*-------------------------------------------------------*
START-OF-SELECTION.
select siselid fieldname sisel
FROM UCT200G INTO TABLE it_uct200g
WHERE fieldname = '/BIC/ZVTYPE1 '
AND sisel = 'PLANNING '.
write: / 'process successful return code = ', sy-subrc.
<b>loop at it_uct200g.</b>
if it_uct200g-sisel = 'PLANNING '.
write: / ' the field is filled'.
endif.
write: / '*****', it_uct200g-siselid,'*',it_uct200g-fieldname,'*',it_uct200g-sisel.
<b>
endloop.</b>
You are doing an array fetch, which means that you are getting all of the data into the internal table all at one shot. You have to then loop at the table to read the records or use the READ TABLE statement to read records directly. This puts the data into the header line where you can access the data.
Regards,
Rich Heilman
‎2006 Jul 27 5:12 PM
I have the program working and it is doing everything that I want it to do. I created this as a program to be able to test it. I now want to copy this code into a method and I am getting a lot of errors on the tables relating to OO context. Is it possible to turn this code into a finction and call this function from the method or do I have to re-code all of the tables to make them conform to OO standards.
thanks in advance
‎2006 Jul 27 5:17 PM
‎2006 Jul 27 5:35 PM
can I use the work areas in my test program and after it is tested and correct, copy the code to the method? it is much easier to test the program than the method.
‎2006 Jul 27 9:05 PM
Hi ,
Just try to change the definition of your internal table as without header line.
<i>data: it_uct200g TYPE STANDARD TABLE OF ty_uct200g with header line.</i>
TO
<b>data: it_uct200g TYPE STANDARD TABLE OF ty_uct200g.</b>
and loop thru the table or read the table whenever you want to access the contents of the table.
Regards,
Raghav
‎2006 Jul 27 9:00 PM
I am having problems setting up the program to use work areas. I have included part of the program. would it be possible for someone to fix what I have coded to have the work aresa properly defined.
thanks in advance
REPORT ZTEST3.
TYPES: BEGIN OF ty_uct200g,
siselid TYPE uct200g-siselid,
fieldname TYPE uct200g-fieldname,
sisel TYPE uct200g-sisel,
END OF ty_uct200g.
data: it_uct200g type ty_uct200g.
data: wa_200g type ty_uct200g.
----
*START-OF-SELECTION *
----
START-OF-SELECTION.
select siselid fieldname sisel
FROM UCT200G INTO wa_200g
WHERE fieldname = '/BIC/ZVTYPE1 '
AND sisel = 'PLANNING '.
write: / 'process successful return code = ', sy-subrc.
loop at ty_uct200g into wa_200g.
write: / 'uct200g****', wa_200g-siselid,'',wa_200g-fieldname,'*',wa_200g-sisel.
endloop.
*
‎2006 Jul 27 9:03 PM
Hi Tim. change like so.
report ztest3.
types: begin of ty_uct200g,
siselid type uct200g-siselid,
fieldname type uct200g-fieldname,
sisel type uct200g-sisel,
end of ty_uct200g.
<b>data: it_uct200g type table of ty_uct200g.
data: wa_200g like line of it_uct200g.</b>
*----------------------------------------------------------------------*
*START-OF-SELECTION *
*----------------------------------------------------------------------*
start-of-selection.
select siselid fieldname sisel
from uct200g into wa_200g
where fieldname = '/BIC/ZVTYPE1 '
and sisel = 'PLANNING '.
* write: / 'process successful return code = ', sy-subrc.
loop at ty_uct200g into wa_200g.
write: / 'uct200g*****', wa_200g-siselid,'*',wa_200g-fieldname,'*',
wa_200g-sisel.
endloop.
*
Please make sure to award points for helpful answers and mark your post as solved when you question has been ansewred.
Thanks.
Regards
Rich HEilman
Message was edited by: Rich Heilman
‎2006 Jul 27 9:11 PM
Rich,
I tried your suggestion and receive the following
<b>"the field "TY_UCT200G" is unknown, but there is a field with the similar name "IT_UCT200G".</b>
‎2006 Jul 27 9:30 PM