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

ABAP simple question

Former Member
0 Likes
1,521

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,470

Hi John ,

Please try using TABLES instead of CHANGING for the subroutine.

Regards,

Arun

14 REPLIES 14
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,470

Is your table it_items populated ?

Read only

Former Member
0 Likes
1,470

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.

Read only

former_member189059
Active Contributor
0 Likes
1,470

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.

Read only

0 Likes
1,470

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?

Read only

0 Likes
1,470

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

Read only

0 Likes
1,470

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

Read only

0 Likes
1,470

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

Read only

0 Likes
1,470

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_table

Though, I noticed that the type ftpost doesn't have a field named item.. in my ECC6 server at least

Read only

Former Member
0 Likes
1,471

Hi John ,

Please try using TABLES instead of CHANGING for the subroutine.

Regards,

Arun

Read only

0 Likes
1,470

tables is obsolete now instead we should use changing with table type as type.

Read only

0 Likes
1,470

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.

Read only

Former Member
0 Likes
1,470

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.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,470

>

> 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

Read only

0 Likes
1,470

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.