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

Regarding read table.

former_member187400
Active Contributor
0 Likes
888

Hi All,

Could you suggest me regarding this please .. ?

If i wanna have the condition for read table not equal .. How can i make it .. ?

e.g. Read table

READ TABLE it_cvn_tmp WITH KEY ZMTCLGR1 = wa_cvn-ZMTCLGR1
                              ZKEYSPEC = wa_cvn-ZKEYSPEC
                              ZBRGHTNS = wa_cvn-ZBRGHTNS
                              AGENTNO = wa_cvn-AGENTNO
                              BPARTNER IS NOT wa_cvn-BPARTNER
                              BP_ACTIVIT = wa_cvn-BP_ACTIVIT
                              ACTIVITYID <> wa_cvn-activityid
                              ZFLAG <> 'I'.

When i run that code, i got an error. And it's caused by the operator/logic "<>".

Could you suggest me what i've to do .. if i wanna make the logic like that ??

/ Is that any command beyond read table where i can read an internal table ...

Many thanks.

Regards,

Niel.

1 ACCEPTED SOLUTION
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
872

READ TABLE it_cvn_tmp WITH KEY ZMTCLGR1 = wa_cvn-ZMTCLGR1

ZKEYSPEC = wa_cvn-ZKEYSPEC

ZBRGHTNS = wa_cvn-ZBRGHTNS

AGENTNO = wa_cvn-AGENTNO

BPARTNER IS NOT wa_cvn-BPARTNER

BP_ACTIVIT = wa_cvn-BP_ACTIVIT

ACTIVITYID <> wa_cvn-activityid

where ZFLAG <> 'I'.

read table can only be done with EQ.

If u want to include NE do this way.

READ TABLE it_cvn_tmp WITH KEY ZMTCLGR1 = wa_cvn-ZMTCLGR1

ZKEYSPEC = wa_cvn-ZKEYSPEC

ZBRGHTNS = wa_cvn-ZBRGHTNS

AGENTNO = wa_cvn-AGENTNO

BPARTNER IS NOT wa_cvn-BPARTNER

BP_ACTIVIT = wa_cvn-BP_ACTIVIT.

if sy-subrc = 0.

if it_cvn_tmp-ACTIVITYID <> wa_cvn-activityid and it_cvn_tmp-ZFLAG <> 'I'.

write ur code here.

endif.

endif.

reward if usefull...:-)

9 REPLIES 9
Read only

Former Member
0 Likes
872

Hi,

For this requirement, you can try LOOP statement -

LOOP AT it_cvn_tmp WHERE ZMTCLGR1 = wa_cvn-ZMTCLGR1 AND

ZKEYSPEC = wa_cvn-ZKEYSPEC AND

ZBRGHTNS = wa_cvn-ZBRGHTNS AND

AGENTNO = wa_cvn-AGENTNO AND

BPARTNER IS NOT wa_cvn-BPARTNER AND

BP_ACTIVIT = wa_cvn-BP_ACTIVIT AND

ACTIVITYID <> wa_cvn-activityid AND

ZFLAG <> 'I'.

EXIT

ENDLOOP.

IF SY-SUBRC EQ 0.

  • Your processing for successful records

ELSE

  • Your processing for failed records

ENDIF.

Hope this helps.

ashish

Message was edited by:

Ashish Gundawar

Read only

Former Member
0 Likes
872

You cannot use <> in a read statement. But you can leave off the

ACTIVITYID <> wa_cvn-activityid

And do the READ without it. That will position the program at the first record that meets the rest of the criteria. Then you loop at the table from that index postion checking the <> condition and the key fields. When the key fields change, exit the loop.

Rob

Read only

Former Member
0 Likes
872

Try with IS NOT instead of using <> symbol....

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
873

READ TABLE it_cvn_tmp WITH KEY ZMTCLGR1 = wa_cvn-ZMTCLGR1

ZKEYSPEC = wa_cvn-ZKEYSPEC

ZBRGHTNS = wa_cvn-ZBRGHTNS

AGENTNO = wa_cvn-AGENTNO

BPARTNER IS NOT wa_cvn-BPARTNER

BP_ACTIVIT = wa_cvn-BP_ACTIVIT

ACTIVITYID <> wa_cvn-activityid

where ZFLAG <> 'I'.

read table can only be done with EQ.

If u want to include NE do this way.

READ TABLE it_cvn_tmp WITH KEY ZMTCLGR1 = wa_cvn-ZMTCLGR1

ZKEYSPEC = wa_cvn-ZKEYSPEC

ZBRGHTNS = wa_cvn-ZBRGHTNS

AGENTNO = wa_cvn-AGENTNO

BPARTNER IS NOT wa_cvn-BPARTNER

BP_ACTIVIT = wa_cvn-BP_ACTIVIT.

if sy-subrc = 0.

if it_cvn_tmp-ACTIVITYID <> wa_cvn-activityid and it_cvn_tmp-ZFLAG <> 'I'.

write ur code here.

endif.

endif.

reward if usefull...:-)

Read only

0 Likes
872

also include the bpartner in the if condition below....

Read only

Former Member
0 Likes
872

Hi

Have You Checked ..

READ TABLE it_cvn_tmp WITH KEY ZMTCLGR1 = wa_cvn-ZMTCLGR1

ZKEYSPEC = wa_cvn-ZKEYSPEC

ZBRGHTNS = wa_cvn-ZBRGHTNS

AGENTNO = wa_cvn-AGENTNO

BPARTNER IS NOT wa_cvn-BPARTNER

BP_ACTIVIT = wa_cvn-BP_ACTIVIT

ACTIVITYID NE wa_cvn-activityid

ZFLAG NE 'I'.

Not sure give it a try ..

Praveen.

Read only

harimanjesh_an
Active Participant
0 Likes
872

hi niel,

Try this,

READ TABLE it_cvn_tmp WITH KEY ZMTCLGR1 = wa_cvn-ZMTCLGR1

ZKEYSPEC = wa_cvn-ZKEYSPEC

ZBRGHTNS = wa_cvn-ZBRGHTNS

AGENTNO = wa_cvn-AGENTNO

BPARTNER IS NOT wa_cvn-BPARTNER

BP_ACTIVIT = wa_cvn-BP_ACTIVIT

ACTIVITYID <b>NE</b> wa_cvn-activityid

ZFLAG <b>NE</b> 'I'.

Reward me if useful.........

Harimanjesh AN

Read only

former_member187400
Active Contributor
0 Likes
872

Tks all for all your response.

Regards,

Niel.

Read only

Former Member
0 Likes
872

Hi,

I would still suggest using LOOP AT...EXIT...ENDLOOP..

Instead of READ TABLE..Then comparing using IF statement..This solution may not work all the times..

Thanks

Naren