Application Development 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: 

Explanations on an abap code

amine_lamkaissi
Active Contributor
0 Kudos

Hi experts,

I found an abap code, i would like to understand it:

DATA: checkbox_mark TYPE xfeld.

FORM at_call .

   IF sy-ucomm EQ 'COM1'.

     CASE x_call.

       WHEN 'X'.

         checkbox_mark = 'S'.

       WHEN space.

         checkbox_mark = 'D'.

     ENDCASE.

   ELSEIF sy-ucomm EQ 'COM2'.

     CLEAR x_call.

   ENDIF.

ENDFORM. "

The logic seems to be simple,but the part that i don't undersand is:


IF sy-ucomm EQ 'COM1'.  --> What values COM1 and COM2 mean?

checkbox_mark = 'S'. --> What values S and D mean?

Thanks.

Amine




1 ACCEPTED SOLUTION

adam_krawczyk1
Contributor
0 Kudos

Hi Amine,

COM1 and COM2 are IDs of commands that were executed. It is used to recognize which button for example was pressed (which command - that is why COM).

XFELD type description is "Checkbox", then I guess that 'S' is selected and 'D' deselected?

Regards,

Adam

7 REPLIES 7

adam_krawczyk1
Contributor
0 Kudos

Hi Amine,

COM1 and COM2 are IDs of commands that were executed. It is used to recognize which button for example was pressed (which command - that is why COM).

XFELD type description is "Checkbox", then I guess that 'S' is selected and 'D' deselected?

Regards,

Adam

0 Kudos

Hi Adam,

Thanks for you answer.

I am building a new program based on what i found, and your explanations unlocked me.

Amine

former_member209119
Active Participant
0 Kudos

Hi Amine,

Just looking at this code no one will be able to tell you purpose of COM1, COM2, S and D.

Basically SY-UCOMM is the Function code that PAI triggers. for every event like SAVE, DELETE, MODIFY, BACK, EXIT etc, corresponding function code is assigned in SY-UCOMM.

So the easiest way for you to know value of sy-ucomm is, just put a break point in your code at IF condition. i.e

IF sy-ucomm EQ 'COM1'.

also notice which operation you have choosen..like SAVE, DELETE..etc.

For checkbox_mark value (S,D) you need to check the scope and usage of checkbox_mark.

arindam_m
Active Contributor
0 Kudos

Hi,

COM1 and COM2 are Function codes that are assigned to buttons on screen. SY-UCOMM captures user clicks on screens. Each BUTTON or RADIO-BUTTON is assigned function codes they can be seen in screen painter when we open that screen. So when user clicks it the System variable gets populated with the FUNCTION code like COM1 or COM2 or as the design may be. Then the programmer can process based on the USER input.

For the 'S' and 'D' thing, look like the variable checkbox_mark gets populated with that value. My guess would be they are indicators indicating Type of account like D =Customer and S= General ledger.

Cheers,

Arindam

former_member458055
Participant
0 Kudos

Hi Amine,

Can you please go to the PF status of that tcode and check for which button that com1 and com2

are assigned. I am sure you wil come to know the meaning of com1 and com2.

Thanks

Makarand

Venkat_Sesha
Advisor
Advisor
0 Kudos

Hi Amine,

In the above mentioned Example Checkbox_mark is declared with Type Reference to XFELD. The Data element holds only either X or SPACE. Whatever you pass to it, It takes it. Though in the Data Element there is a Fixed values to this field. If you Pass 'S' it will take 'S'. Its not a Valid code AFAIK.

It should be like this.

     CASE x_call.

       WHEN 'X'.

         checkbox_mark = 'X'.

       WHEN space.

         checkbox_mark = ' '.

     ENDCASE.

Anyhow I dont say it is incorrect. But what I am trying to say is the Fixed values are defined to this Field as X or SPACE, then why do we pass 'S" or 'D" it is like more of programming internal usage purpose.

This is assumption only: XFELD type description is "Checkbox", then I guess that 'S' is selected and 'D' deselected.

Hope this helps.

amine_lamkaissi
Active Contributor
0 Kudos

Thanks guys.

Amine