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

Select statement in Infoset

Former Member
0 Likes
723

Hi all,

Being a FICO member, while doing infoset creation i have an issue with the select statement.

I have a Z* field in my infoset, output for this field would come by below select statement.

select BELNR from BSIS into ZBELNR

where zuonr = bseg-zuonr

and blart = 'RE'

and bukrs = bseg-bukrs

and wrbtr = bseg-wrbtr.

endselect.

select BELNR from BSAS into ZBELNR

where zuonr = bseg-zuonr

and blart = 'RE'

and bukrs = bseg-bukrs

and wrbtr = bseg-wrbtr.

endselect.

Basically, if i give any one of the above select statements, it is working fine. But my intention is to first check with BSIS, and if records found, then there is no need of using BSAS select statement. If not founf it should check with BSAS again.

Can anybody modify my code, in order to get my requirement.

Regards,

Srinu

Hi all,

Being a FICO member, while doing infoset creation i have an issue with the select statement.

I have a Z* field in my infoset, output for this field would come by below select statement.

select BELNR from BSIS into ZBELNR

where zuonr = bseg-zuonr

and blart = 'RE'

and bukrs = bseg-bukrs

and wrbtr = bseg-wrbtr.

endselect.

select BELNR from BSAS into ZBELNR

where zuonr = bseg-zuonr

and blart = 'RE'

and bukrs = bseg-bukrs

and wrbtr = bseg-wrbtr.

endselect.

Basically, if i give any one of the above select statements, it is working fine. But my intention is to first check with BSIS, and if records found, then there is no need of using BSAS select statement. If not founf it should check with BSAS again.

Can anybody modify my code, in order to get my requirement.

Regards,

Srinu

3 REPLIES 3
Read only

Former Member
0 Likes
551

Hi,

Just put the second select inside a IF-ENDIF

IF sy-subrc NE 0.
  SELECT belnr FROM bsas INTO zbelnr......
ENDIF.

atb

Read only

0 Likes
551

Hi Doru,

Your inputs helped me a lot.

Then i modified my code like below for Z* field (ZBELNR)

select BELNR from BSIS into ZBELNR
  where zuonr = bseg-zuonr
  and blart = 'RE'
  and bukrs = bseg-bukrs
  and dmbtr = bseg-dmbtr.
endselect.
if sy-subrc NE 0.
  select BELNR from BSAS into ZBELNR
  where zuonr = bseg-zuonr
  and blart = 'RE'
  and bukrs = bseg-bukrs
  and dmbtr = bseg-dmbtr.
  endselect.
endif.

But here i have an issue with data over flow.

i have 3 document numbers at selection screen (in one selection field) for my report.

As per the data available in system, against my 3 selection document numbers, for my above said zfield (ZBELNR), for the 1st record- data is not available for ZFIELD (ZBELNR)

2nd record data is available for ZFIELD (ZBELNR)

3rd record - data is not available for ZFIELD (ZBELNR)

but the problem is that, in the output, for 1st record it is not showing anything ( this is correct)

for 2nd record, data is showing ( this is correct)

for 3rd record data should not come, but still it is coming (ZBELNR value of the 2nd record) WRONG

Seems like data overflow in the above code.

Can you please suggest me on this.

Regards,

Srinu

Read only

0 Likes
551

Insert

CLEAR ZBELNR.

before the 1st SELECT statement

It would also be fine for runtime not to search for all entries, if you need only one.

Use SELECT SINGLE (without ENDSELECT) or use EXIT in SELECT loop or serach for highest BELNR with MAX( BELNR ) ...

Regards

Klaus