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

ALV-SELFIELD

Former Member
0 Likes
2,640

Hi,

I'm creating an interactive ALV list.

When the user clicks on a column, I need to capture the filedname.

i'm using the code:

form call_ucommand

using ucomm like sy-ucomm

selfield type kkblo_selfield.

......

.....

end from.

when i click on a column, i'm able to capture tablename, value and index (into selfield-tabname, selfield-value, selfield-tabindex), but i'm not getting field name. How come it's happening. Pls help me on this.

Regards,

Ravi.

7 REPLIES 7
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,424

rs_selfield-fieldname or rs_selfield-sel_tab_field should be the field name, look at rs_selfield-endsum and rs_selfield-sumindex if the cursor is on the total or a sub-total line.

Also look for [samples at sdn|https://www.sdn.sap.com/irj/sdn/advancedsearch?query=alvuser_commandrs_selfield&cat=sdn_all].

Regards

Read only

Former Member
0 Likes
1,424

Hi frn ,

please follow this code ,

FORM DISPLAY_DOCUMENT USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

IF RS_SELFIELD-FIELDNAME = 'VBELN'.

READ TABLE T_ITAB INDEX RS_SELFIELD-TABINDEX .

V_VBELN = T_ITAB-VBELN.

LOOP AT T_ITAB WHERE VBELN = V_VBELN.

Move: T_ITAB-POSNR to T_ITAB1-POSNR ,

T_ITAB-MATNR to T_ITAB1-MATNR ,

T_ITAB-MATKL to T_ITAB1-MATKL,

T_ITAB-ARKTX to T_ITAB1-ARKTX ,

T_ITAB-PSTYV to T_ITAB1-PSTYV ,

T_ITAB-SPART to T_ITAB1-SPART ,

T_ITAB-GSBER to T_ITAB1-GSBER ,

T_ITAB-KWMENG to T_ITAB1-KWMENG .

Append T_ITAB1.

ENDLOOP.

ENDIF.

Thanks And Regards

Priyank dixit

Read only

0 Likes
1,424

Hi,

you have to write a subroutine lets its name be USER_COMMAND.

write the subroutine in the program.

like below given:

FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

...............

.....................

ENDFORM.

and provide the subroutine name in the parameter USERCOMMAND of function module REUSE_ALV_GRID_DISPLAY.

So when user do some activity on ALV report then the program will come this subroutine.

And the structure RS_SELFIELD will have different information i.e. fieldname,index,and the selected field's value.

you can check it in debugger.

hope this will help you.

Read only

Former Member
0 Likes
1,424

Hi,

If you still have the problem, share your Code.......FM call & the User_command Subroutine.

Read only

Former Member
0 Likes
1,424

Hi Ravi,

I guess the structure selfield-fieldname contains the fieldname which the user has selected.

Thanks,

Chidanand

Read only

0 Likes
1,424

Hi,

Guys, my code is working fine. When I click on variables i printed on top_of_page, I'm able to catch fieldname and value.

the problem is when i select values in the list display (values from i_out used in ALV function module) i'm NOT getting field name. I'm getting value, tablename and index.

regards,

Ravi.

Read only

0 Likes
1,424

Hi,

Finally I got the bug. I'm able to catch selfield-fieldname for varaiables i'm printing in top of page but couldn't when I double click on the rows of the list.

THE SILLY REASON BEHIND THIS IS THE INTERNAL OUTPUT TABLE SHOULD BE DECLARED WITH HEADER LINE.

*I'm coding in SAP 3.1 version. This may be a drawback in that version. I don't think this would happen with SAP 4.7 and advanced versions.

Regards,

Ravi.