Application Development 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: 

Passing data of internal table to a form/subroutine

former_member184874
Participant
0 Kudos

I have used the IF/ElSE statement to get data in an Internal Table say ITAB1 on base of some parameters. If ITAB1 IS NOT INITIAL it will PERFORM FORM_FILL.

FORM_FILL takes the ITAB1 data and filters it on certain parameters, and READ TABLE is done to get data from other tables. I want to know the method of passing the ITAB1 data to the FORM_FILL subroutine.

How can I do this?

Moderator Message - Basic ABAP syntax question. Thread locked.

Message was edited by: Suhas Saha

11 REPLIES 11

Former Member
0 Kudos

Hi,

You can write like this..

Declare itab1 globally. and write like below.

PERFORM FORM_FILL using itab1.

Regards

Ram

0 Kudos

hi,

If your using FM declare lit(internal table ) in top include,,,,

for local internal table use TABLES to pass internal table.

perform update_table tables lit .

form update_table tables lit  structure ztt.

ztt should be type of lit.  if standerd structure not there you have to create zstructure.

regards.

Lingaraj.

kakshat
Advisor
Advisor
0 Kudos

If you want to use local variables, it is better to use USING/CHANGING instead of TABLES. TABLES is an old way of passing internal tables.

reachdebopriya
Active Participant
0 Kudos

Hi,

Suppose the structure name is ty_itab, internal table name is t_itab1. Table Type is tty_itab1.

TYPES: tty_itab1 TYPE STANDARD TABLE of ty_itab.

PERFORM FORM_FILL CHANGING t_itab1.

FORM FORM_FILL CHANGING t_itab1 type tty_itab1.

*-- Business Logic

ENDFORM.

Regards,

Debopriya Ghosh

Venkat_Sesha
Advisor
Advisor
0 Kudos

Hi Das,

Check the below code.

Perfrom TEST_FORM TABLES ITAB

                                 USING WA.

In the Form----EndForm the code will be like this.

FORM TEST_FORM TABLES P_ITAB

                               USING P_WA.

-----------------Your Code-------------------

ENDFORM.

Remember the only Rule is whenever you are using TABLES Parameter in the PERFORMs it should be the First One later you can add USING , CHANGING etc.. Hope this helps.

0 Kudos

Sesha solution is the near one. I don't want to use global declaration.

0 Kudos

SELECT ZBSDV ZINDV VKBUR KUNNR ZMODEL AUART VBELN AUDAT BNDDT FROM VBAK INTO TABLE IT_VBAK
             WHERE AUDAT IN P_DAT AND AUART = P_AUART.
            ENDIF.
          

IF IT_VBAK IS NOT INITIAL.
PERFORM FILL_FINAL TABLES IT_VBAK USING WA_VBAK.


FORM FILL_FINAL TABLES IT_VBAK USING WA_VBAK.

*********** code***************

ENDFORM.

Gives error data object "WA_VBAK" has no structure and therefore no component called BNDDT

0 Kudos

Hi Das,

Check the below code and try it will work. Hope this helps

PERFORM FILL_FINAL TABLES IT_VBAK USING WA_VBAK. 


FORM FILL_FINAL TABLES IT_VBAK

                               USING P_WA_VBAK Like WA_VBAK.

*********** code***************

* Here you use the P_WA_VBAK as WA_VBAK.

ENDFORM.

Former Member
0 Kudos

Hello Soumen,

   Do you want to just pass internal table to refer in routine or you want to make changes. If it global declaration that you can use it directly without passing it in form routine. If still you need to access thru routine then check below logic

PERFORM FORM_FILL TABLES t_itab1.

***************************************************

FORM FORM_FILL TABLES t_itab1.

*.............

Logic

............

ENDFORM.

regards,

Deepti

SharathSYM
Contributor
0 Kudos

Options for you:-

FORM subroutine CHANGING pi_table LIKE i_table

FORM subroutine TABLES pi_table TYPE STANDARD TABLE

FORM subroutine TABLES pi_table STRUCTURE dictionary_structure

FORM subroutine CHANGING pi_table TYPE table_type



Former Member
0 Kudos

Hi Souman

If your table data needs to be modified or changed and gets returned from the subroutine then you can use:

Perform Form_fill changing itab1.

Form Form_fill changing ITAb1 type <type of itab1>.

....

.....

ENDFORM.

or if you simply wants to pass the data from data from table :

use value instead of changing.

regards

vaibhav