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

Read table and checking condition in PAI

Former Member
0 Likes
1,927

Hi,

I have a requirement where I need to check and compare with (Custom table) Bankn with Partner Bank`s bankn.

I have wrote a code in PAI like this.

MODULE CHECK_BANKN INPUT.

   Data: l_bankn like (Custom table)-bankn.

   select bankn from (Custom Table) into l_bankn

       where recno = g_recno.

   IF NOT g_head-bankn IS INITIAL.

  Read table i_bvtyp with key bankn = i_bvtyp-bankn .

     IF l_bankn <> i_bvtyp-bankn.--------->" Comparison of (custom table) Bankn with internal table I_BVTYP-BANKN

       MESSAGE w022 WITH text-w06.

     ENDIF.

   ENDIF.

ENDMODULE.

My Read Table statement is seems to be wrong and my checking condition is also wrong.

So, how to resolve this?

regards,

Kiran

1 ACCEPTED SOLUTION
Read only

SharathYaralkattimath
Contributor
0 Likes
1,744

Hi Kiran,

Do a sy-subrc check after your select & READ statements.

Then proceed with your code.

Thanks,

Sharath

Hi,

I have a requirement where I need to check and compare with (Custom table) Bankn with Partner Bank`s bankn.

I have wrote a code in PAI like this.

MODULE CHECK_BANKN INPUT.

   Data: l_bankn like (Custom table)-bankn.

   select bankn from (Custom Table) into l_bankn

       where recno = g_recno.

   IF NOT g_head-bankn IS INITIAL.

  Read table i_bvtyp with key bankn = i_bvtyp-bankn .

     IF l_bankn <> i_bvtyp-bankn.--------->" Comparison of (custom table) Bankn with internal table I_BVTYP-BANKN

       MESSAGE w022 WITH text-w06.

     ENDIF.

   ENDIF.

ENDMODULE.

My Read Table statement is seems to be wrong and my checking condition is also wrong.

So, how to resolve this?

regards,

Kiran

12 REPLIES 12
Read only

SharathYaralkattimath
Contributor
0 Likes
1,745

Hi Kiran,

Do a sy-subrc check after your select & READ statements.

Then proceed with your code.

Thanks,

Sharath

Read only

0 Likes
1,744

Ok. i will do the sy-subrc ..

but I need to read i_bvtyp using g_head    

(my custom table is in g_head)

I need a proper read statement

regards,

Kiran

Read only

Former Member
0 Likes
1,744

Hi,

     First Check i_bvtyp-bankn and l_bankn both are of same type and length

     Second add Sy-Subrc eq 0 after read table

     Read table i_bvtyp with key bankn = i_bvtyp-bankn .

     if sy-subrc = 0 .

          .........

     endif

Read only

VijayaKrishnaG
Active Contributor
0 Likes
1,744

Hi Kiran,

If you observe your read statement, you are comparing the field with it's own table field.


   Read table i_bvtyp with key bankn = i_bvtyp-bankn .

Untill unless you read I_BVTYP, i_bvtyp-bankn will be initial and you cannot find the matching record with Null-Value.

So, I think you need compare with l_bankn.

   Read table i_bvtyp with key bankn = i_bankn .

Then you can directly raise a message using SY-SUBRC value.

   Read table i_bvtyp with key bankn = i_bankn

      if SY-SUBRC <> 0 .

          <MESSAGE>    

     endif.

Regards,

Vijay

Read only

0 Likes
1,744

Hi...bit slight change in code.. instead of using custom table, i can use G_HEAD for it..

Here I have to do is like need to read i_bvtyp using g_head if not found, Warning message

So, over all, how can i update the code?

IF NOT g_head-bankn IS INITIAL.

Read table i_bvtyp with key bankn = bankn .

if Sy-subrc NE 0.

<message>

Endif.

Endif.

Like this??   Where is the comparison ??

Read only

0 Likes
1,744

Hi,

Then your READ statement should be as follows:

READ TABLE I_BVTYP WITH KEY BANK = G_HEAD-<bank_number_field>.

IF    SY-SUBRC <> 0.

     <message>

ENDIF.

Regards,

Vijay

Read only

Former Member
0 Likes
1,744

Hi Kiran,

select SINGLE bankn from (Custom Table) into l_bankn 

       where recno = g_recno.

regards,

Archer

Read only

Former Member
0 Likes
1,744

Please check Read table i_bvtyp with key bankn = i_bvtyp-bankn .

Do you want check with condition bankn = i_bvtyp-bankn?

Regards,

Venkat.

Read only

Former Member
0 Likes
1,744

Hi all,

our custom table is stored in G_HEAD.

I have to read i_bvtyp using g_head, if not found Warning msg need to come

Please help me out

Regards,

Kiran

Read only

0 Likes
1,744

Then your READ statement should be as follows:

READ TABLE I_BVTYP WITH KEY BANK = G_HEAD-<bank_number_field>.

Regards,

Vijay

Read only

Former Member
0 Likes
1,744

Hi,

For not equal to condition Read table statement cannot be used , instead use loop statement.

Example:

loop at  i_bvtyp where bankn <> g_head-bankn.

EXIT.

endloop.

Read only

VijayaKrishnaG
Active Contributor
0 Likes
1,744

Hi Kiran,

Did you get the solution for your query?? If yes, please close the thread.

Regards,

Vijay