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

Checking FM table entries against database table entries

Former Member
0 Likes
485

Hello!

I'm creating a function module with table input parameters IT_OBJECT and output parameters IT_OBJECT_INS.

Also i'm creating ZTABLE with 6 fields. Some of these are the POBJECT and POBJECT_REF which are key fields.

If input parameter IT_OBJECT is populated, the process in the FM would be:

- to check if the data in the input parameter table exists in ZTABLE, that is ZTABLE-POBJECT IN IT_OBJECT

- ZTABLE-POBJECT_REF EQ ' '.

if the above conditions are satisfied I have to retrieve POBJECTS from ZTABLE.

QUESTION: I'm just not sure on how will I do the checking of the entries in IT_OBJECT against the entries in ZTABLE?

Thanks!

Bay

1 ACCEPTED SOLUTION
Read only

naimesh_patel
Active Contributor
0 Likes
461

DO like this...

Create one more internal table which can store the data from the ZTABLE like IT_ZTAB.

Than, code like this

SELECT * FROM ZTABLE
INTO IT_ZTAB
FOR ALL ENTRIES IN IT_OBJECT
WHERE POBJECT = IT_OBJECT-POBJECT
AND POBJECT_REF EQ ' '.

LOOP AT IT_OBJECT.
READ TABLE IT_ZTAB WITH KEY POBJECT = IT_OBJECT-POBJECT.
IF SY-SUBRC = 0.
*** ENTRY FOUND
ENDIF.
ENDLOOP.

Regards,

Naimesh Patel

Hello!

I'm creating a function module with table input parameters IT_OBJECT and output parameters IT_OBJECT_INS.

Also i'm creating ZTABLE with 6 fields. Some of these are the POBJECT and POBJECT_REF which are key fields.

If input parameter IT_OBJECT is populated, the process in the FM would be:

- to check if the data in the input parameter table exists in ZTABLE, that is ZTABLE-POBJECT IN IT_OBJECT

- ZTABLE-POBJECT_REF EQ ' '.

if the above conditions are satisfied I have to retrieve POBJECTS from ZTABLE.

QUESTION: I'm just not sure on how will I do the checking of the entries in IT_OBJECT against the entries in ZTABLE?

Thanks!

Bay

2 REPLIES 2
Read only

naimesh_patel
Active Contributor
0 Likes
462

DO like this...

Create one more internal table which can store the data from the ZTABLE like IT_ZTAB.

Than, code like this

SELECT * FROM ZTABLE
INTO IT_ZTAB
FOR ALL ENTRIES IN IT_OBJECT
WHERE POBJECT = IT_OBJECT-POBJECT
AND POBJECT_REF EQ ' '.

LOOP AT IT_OBJECT.
READ TABLE IT_ZTAB WITH KEY POBJECT = IT_OBJECT-POBJECT.
IF SY-SUBRC = 0.
*** ENTRY FOUND
ENDIF.
ENDLOOP.

Regards,

Naimesh Patel

Read only

0 Likes
461

Thanks Naimesh.

You got points from me.

Regards,

Bay