‎2010 Jul 01 9:29 PM
Hello everyone,
I have a question. In my Z program I have a zprogramname_top where my variables/tables are defined and a zprogramname_f01 where i make calculations.
in f01, i call another form where I fill a table, but when I retunr to the calling perform, that table is empty.
What am I doing wrong?
Example:
Data declaration:
data: ti_ftpost LIKE ftpost OCCURS 0 WITH HEADER LINE.
F01:
form prepare_table.
loop at it_items.
perform fill_table using it_items-pos
changing ti_ftpost
endloop.
endform.
form fill_table using p_item
changing ti_ftpost.
ti_ftpost-item = p_item.
append ti_ftpost.
clear ti_ftpost.
endform.
Moderator message: please use more descriptive subject lines and code tags from now on.
Edited by: Thomas Zloch on Jul 2, 2010 2:24 PM
‎2010 Jul 02 9:06 AM
Hi John ,
Please try using TABLES instead of CHANGING for the subroutine.
Regards,
Arun
‎2010 Jul 02 3:02 AM
‎2010 Jul 02 8:19 AM
Dear Suhas Saha.
my table it_items is populated. Has I said, in the form fill_table my table is filled, but when the program returns to form prepare_table the table content is empty.
Thanks for your help.
‎2010 Jul 02 4:49 AM
Hello,
Try these changes
data: ti_ftpost LIKE ftpost OCCURS 0 WITH HEADER LINE.
types: t_post like ti_ftpost. " added
F01:
form prepare_table.
loop at it_items.
perform fill_table using it_items-pos
changing ti_ftpost[]. " changed
endloop.
endform.
form fill_table using p_item
changing ti_ftpost type t_post. " changed
data: wa_post like line of ti_ftpost. " added
wa_ftpost-item = p_item. " changed
append wa_ftpost to ti_ftpost. " changed
clear wa_ftpost. " changed
endform.
‎2010 Jul 02 8:17 AM
Hello,
I tried to do like you said Kris Donald, but I get the following error:
In perform fill_table the actual parameter "ti_ftpost" is incompatible with the formal parameter "ti_ftpost"
How can I solve this?
‎2010 Jul 02 8:21 AM
U need to defing in FORM changing ti_ftpost type gty_t_ftpost.
where gty_t_post is declared before as:-
Types: gty_t_ftpost type table of ftpost.
This is done because in perform u r passing the table and while declaring in form u were declaring wrk area whereas it shd be table type.
Edited by: vijetasap on Jul 2, 2010 9:21 AM
‎2010 Jul 02 8:33 AM
Thanks for the quick reply vijetasap,
I still get the same error, saying that the parameter is incompatible. My code is like this:
TOP:
data: ti_ftpost LIKE ftpost OCCURS 0 WITH HEADER LINE.
types: t_post type table of ftpost.
F01:
perform fill_table using it_items-pos
changing ti_ftpost[].
form fill_table using p_item
changing ti_ftpost type t_post
‎2010 Jul 02 8:55 AM
what is the type of it_items-pos? Is it_items table with header line? Does the length of pos equal to 1 ? Check its type also and use same type in Form using parameter
‎2010 Jul 02 9:41 AM
Hello,
Try this
data: ti_ftpost like ftpost occurs 0 with header line.
types: t_post type table of ftpost.
data: begin of wa_items occurs 0,
pos type i,
end of wa_items.
data: it_items like wa_items OCCURS 0 WITH HEADER LINE.
*&---------------------------------------------------------------------*
*& Form prepare_table
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form prepare_table.
loop at it_items.
perform fill_table using it_items-pos
changing ti_ftpost[].
endloop.
endform.
*&---------------------------------------------------------------------*
*& Form fill_table
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_ITEM text
* -->TI_FTPOST text
*----------------------------------------------------------------------*
form fill_table using p_item
changing ti_ftpost type t_post.
data: wa_post like line of ti_ftpost.
wa_post-fnam = p_item.
append wa_post to ti_ftpost.
clear wa_post.
endform. "fill_tableThough, I noticed that the type ftpost doesn't have a field named item.. in my ECC6 server at least
‎2010 Jul 02 9:06 AM
Hi John ,
Please try using TABLES instead of CHANGING for the subroutine.
Regards,
Arun
‎2010 Jul 02 12:04 PM
tables is obsolete now instead we should use changing with table type as type.
‎2010 Jul 02 12:24 PM
yes tables is obsolete., but the table 'ti_ftpost' is a table with header line and in the subroutine the header is used to append data , so i dont think changing helps.
‎2010 Jul 02 12:35 PM
John..
a simple solution... i think problem is with your clear staetment..
ok.. obsolete thing is to be considered later.. but just to make your code work do this.
form fill_table using p_item
changing ti_ftpost.
data : ls_post type ftpost. "==>added
clear ls_post. "==>changed
ls_post-item = p_item. "==>chaned
append ls_post to ti_ftpost. "==>changed
endform.
‎2010 Jul 02 1:40 PM
>
> a simple solution... i think problem is with your clear statement.
Your understanding of the CLEAR statement is not correct for internal tables with header lines.
SAP says:
If dobj is an internal table with a header line, you must specify dobj[] to delete the rows, otherwise only the header line will be deleted.
So your statement is incorrect. For me the problem is not with the CLEAR.
BR,
Suhas
‎2010 Jul 07 11:51 PM
I thought this was an easy question, but it looks like it was not.
I have got it working with the use of obsolete.
Thanks for everyone's help.