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

Function Modules.

Former Member
0 Likes
1,041

I am creating a Function Module and in Export parameter I am giving:

S_vbak like vbak-vbeln.

In tables I am giving:

ITAB like vbak

In source code I am giving :

TABLES:vbak.

SELECT vtweg FROM vbak INTO TABLE itab WHERE vbeln EQ s_vbeln.

LOOP AT itab.

WRITE:itab-vtweg.

endloop.

ENDFUNCTION.

But I am getting Zero entries,can u plz tell the error.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,021

S_vbeln like vbak-vbeln. " S_VBAK is changed to S_VBELN

" In tables I am giving:
data : ITAB type standard table of  vbak.

" In source code I am giving :
TABLES:vbak.

SELECT * FROM vbak INTO TABLE itab WHERE vbeln IN s_vbeln. " EQ changed to IN
LOOP AT itab.
WRITE:itab-vtweg.
endloop.

9 REPLIES 9
Read only

Former Member
0 Likes
1,021

<b>chk vbeln "used this converstion_inpu alphaexit.</b>

S_vbak like vbak-vbeln.

In tables I am giving:

ITAB like vbak

In source code I am giving :

TABLES:vbak.

*chk p_vbeln run time length both are same or not.

SELECT vtweg FROM vbak INTO TABLE itab WHERE <b>vbeln EQ s_vbeln</b>.

<b>if sy-subrc =0. record found else where condition error</b>

LOOP AT itab.

WRITE:itab-vtweg.

endloop.

endif.

ENDFUNCTION.

Read only

Former Member
0 Likes
1,022

S_vbeln like vbak-vbeln. " S_VBAK is changed to S_VBELN

" In tables I am giving:
data : ITAB type standard table of  vbak.

" In source code I am giving :
TABLES:vbak.

SELECT * FROM vbak INTO TABLE itab WHERE vbeln IN s_vbeln. " EQ changed to IN
LOOP AT itab.
WRITE:itab-vtweg.
endloop.

Read only

Former Member
0 Likes
1,021

Hi,

If u r using select-options, U should not use EQ u can use IN.

SELECT vtweg FROM vbak INTO TABLE itab WHERE vbeln IN s_vbeln.

Like this.

Read only

Former Member
0 Likes
1,021

Hello Ajaya,

As per my understanding, in the below select statement, s_vbeln is not assigned with any value. Are you looking for values in vbak with no entry in vblen ? if not may be you need to assign a value to it and then this staement will return you the required output.

SELECT vtweg FROM vbak INTO TABLE itab WHERE vbeln EQ s_vbeln.

Best regards,

Kulwant Singh

Read only

Former Member
0 Likes
1,021

Hi,ajaya.

I think you can try call this function in a program.

Regards,

feng.

Read only

Former Member
0 Likes
1,021

Hi,

If u want to get the entries from VBAk based on S_VBAK,

then give S_VBAK in IMPORT parameters.

U need not write any Loop statement, because u r directly retrieving the values in to ur export table.

Ex:

Import: S_VBELN like VBAK-VBELN.

Tables: ITAB like VBAK.

Source code: Select * from VBAK into table ITAB where VBELN = S_VBELN.

Note: If u want only particular fields to be displayed, then u need to create a structure with these fields and give in Tables parameters.

Read only

Former Member
0 Likes
1,021

read the itab into a structure which has the same type as the table itab.

data: wa type vbak.

loop at itab into wa

write : wa-vtweg.

endloop.

Read only

Former Member
0 Likes
1,021

we will be calling this function module in some program.

right?

so just change the select statement i.e. remove the loop from there.

and try calling the FM in some prg and then you will come to know where exactly you are going wrong.

Message was edited by:

prachi s

Read only

Former Member
0 Likes
1,021

try it with this coding. that one is properly written.

S_vbak like vbak-vbeln.

In tables I am giving:

ITAB like vbak

In source code I am giving :

TABLES:vbak.

SELECT vbeln vtweg FROM vbak INTO corresponding fields of TABLE itab WHERE vbeln EQ s_vbak.

LOOP AT itab.

WRITE:itab-vtweg.

endloop.

ENDFUNCTION.

now it will work.