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

Checkboxes

0 Likes
2,898

When I try to pull data, all checkboxes are working. I want my picks to work, what should I do?

I get the data if 1 checkbox is checked. But if I pull more than one checkbox, I can't get the data. What I want is to be able to view all the data when I click on 2-3 or 4 checkboxes.

 PARAMETERS: cbox0 as CHECKBOX, cbox1 as CHECKBOX, cbox2 as CHECKBOX,cbox3 as CHECKBOX.
SELECT DISTINCT z1~aufnr<br> z2~phas0<br> z2~phas1<br> z2~phas2<br> z2~phas3<br> z2~objnr<br> z2~erdat<br> z2~ernam<br> z2~idat1<br> z2~idat2<br> z2~idat3<br> z3~equnr<br> z4~zzdriver<br> FROM afko AS z1<br> INNER JOIN aufk AS z2 ON ( z1~aufnr = z2~aufnr )<br> INNER JOIN afih AS z3 ON ( z2~aufnr = z3~aufnr )<br> INNER JOIN v_fleet AS z4 ON ( z3~equnr = z4~equnr )<br> INTO CORRESPONDING FIELDS OF TABLE gt_phas<br> WHERE z1~aufnr IN s_aufnr<br> AND ( z2~phas0 EQ cbox0<br> OR z2~phas1 EQ cbox1<br> OR z2~phas2 EQ cbox2<br> OR z2~phas3 EQ cbox3 )<br> AND z2~erdat IN s_erdat<br> AND z3~equnr IN s_equnr<br> AND z4~zzdriver IN s_driver.
16 REPLIES 16
Read only

FredericGirod
Active Contributor
2,804

Use button [CODE] to format your ABAP code

Explain what it is nor working, what you expect to have ...

Are you sure there is lines corresponding to your selection ?

Read only

ThorstenHoefer
Active Contributor
2,804

Hi sahbaz,

you try to select your data with an or condition. Are you sure this is what you want?

AND ( z2~phas0 EQ cbox0
OR z2~phas1 EQ cbox1
OR z2~phas2 EQ cbox2
OR z2~phas3 EQ cbox3 )

If you wan't that all checkboxes has an effect to your selection, you should consider to change it to an "and" condition:

AND  z2~phas0 EQ cbox0
AND z2~phas1 EQ cbox1
AND z2~phas2 EQ cbox2
AND z2~phas3 EQ cbox3
Read only

0 Likes
2,804

If I do it with the and command as you said, if I select more than one checkbox, it does not return the data.

Read only

0 Likes
2,804

Hi Okan,

it is important to know what you want to select. A check box can have either the value true or false. If the combination of checkboxes match to your datarecord, you should be able to select the record.#

Do you want to have a additional logic, for example that only one of the phas can be set?

AND z2~phas0 EQ cbox0
AND z2~phas1 EQ cbox1
AND z2~phas2 EQ cbox2
AND z2~phas3 EQ cbox3
Read only

0 Likes
2,804

My code is as you wrote above. When this happens, if I select one by one, I can access the data, but if I select more than one, the data does not come.

Read only

Sandra_Rossi
Active Contributor
2,804

Please clarify what result you expect with an example, so that people can understand what you have in mind. Thanks.

Read only

0 Likes
2,804

For example, I can see my data when I select cbox1 right now. But if I select more than one checkbox (cbox1 and cbox2) the data is not displayed.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,804

Basically you either select some records with status flag set to 'X' or set to initial value.

  • For example, when you set check box 'CBOX0' you select every record with status 'CREATED' on in your list, when you unset the box you select every record with status 'CREATED' off. And you select with an OR for the 4 provide status flag on the order record.

So

  • When you set only 'CBOX0' you get all records with status 'CREATED'... and you also select every record with status 'RELEASED', 'COMPLETED' or 'CLOSED' not set.
  • When you set the 4 boxes, you get all records with one of the status set.

My questions

  • What do you actually want to select, Do you look for an union of the 4 selected status (as in some standard reports such as RIAUFK20, did you analyze its code)
  • Consider using an impossible value in selection when box is not checked) - when CBOXn is checked, value 'X', then check with value 'X' but when it's not checked, value initial, check with value '#' (and keep the OR) you could even build a variable for a dynamic selection. (e.g. 'PHAS0 = 'X' OR PHAS1 = 'X') and add it to the WHERE clause.
Read only

0 Likes
2,804

I get the data if 1 checkbox is checked. But if I pull more than one checkbox, I can't get the data. What I want is to be able to view all the data when I click on 2-3 or 4 checkboxes.

Read only

ThorstenHoefer
Active Contributor
0 Likes
2,804

Hi,

maybe this is the code you want?

AND ( z2~phas0 EQ cbox0 or z2~phas0 is initial )
AND ( z2~phas1 EQ cbox1 or z2~phas1 is initial )
AND ( z2~phas2 EQ cbox2 or z2~phas2 is initial )
AND ( z2~phas3 EQ cbox3 or z2~phas3 is initial )
Read only

0 Likes
2,804

Thank you but it didn't work for me.

Read only

0 Likes
2,804

or, depending on actual OP requirement

AND ( ( z2~phas0 EQ cbox0 AND z2~phas0 is not initial ) " select if status CREATED and box checked
   OR ( z2~phas1 EQ cbox1 AND z2~phas1 is not initial ) " select if status RELEASED and box checked 
   OR ( z2~phas2 EQ cbox2 AND z2~phas2 is not initial ) " etc.
   OR ( z2~phas3 EQ cbox3 AND z2~phas3 is not initial ) )
Read only

0 Likes
2,804

When I do as you say, I pull all the data. I just want my chosen ones to come.

Read only

FredericGirod
Active Contributor
0 Likes
2,804

Your code works for me, after some adaptations, I have PHAS1 = X PHAS... = blank

but it works whatever I check

TABLES: aufk, afih.
PARAMETERS: cbox0 AS CHECKBOX, cbox1 AS CHECKBOX, cbox2 AS CHECKBOX,cbox3 AS CHECKBOX.
SELECT-OPTIONS s_aufnr FOR aufk-aufnr.
SELECT-OPTIONS s_erdat FOR aufk-erdat.
SELECT-OPTIONS s_equnr FOR afih-equnr.


SELECT DISTINCT z1~aufnr,
 z2~phas0,
 z2~phas1,
 z2~phas2,
 z2~phas3,
 z2~objnr,
 z2~erdat,
 z2~ernam,
 z2~idat1,
 z2~idat2,
 z2~idat3,
 z3~equnr
  FROM afko AS z1
 INNER JOIN aufk AS z2 ON ( z1~aufnr = z2~aufnr )
 INNER JOIN afih AS z3 ON ( z2~aufnr = z3~aufnr )
* INNER JOIN v_fleet AS z4 ON ( z3~equnr = z4~equnr )
 INTO TABLE @DATA(gt_phas)
 WHERE z1~aufnr IN @s_aufnr
 AND ( z2~phas0 EQ @cbox0
 OR z2~phas1 EQ @cbox1
 OR z2~phas2 EQ @cbox2
 OR z2~phas3 EQ @cbox3 )
 AND z2~erdat IN @s_erdat
 AND z3~equnr IN @s_equnr.
Read only

Sandra_Rossi
Active Contributor
0 Likes
2,804

I don't think it clarifies anything. If it doesn't select it's because table AUFK doesn't have a line which has both PHAS0 = 'X' and PHAS1 = 'X' (in relationship with the joined lines). No magic here.

Maybe you can simplify your code to understand what's going on. First try with AUFK alone to make sure you select the lines you want, then add one table at a time to see when the lines are not selected anymore, and analyze why.

SELECT * FROM aufk WHERE
z2~phas0 EQ @cbox0 OR z2~phas1 EQ @cbox1 OR z2~phas2 EQ @cbox2 OR z2~phas3 EQ @cbox3 ...
Read only

0 Likes
2,804

I'm using a pre 7.40 sap system @use doesn't work