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

Get Cursor

0 Likes
1,082

Hello Experts,

Im trying to generate a secondary list using get cursor i/p range of mat no. when the user double clicks on mat no. it should display the selected material no. in sec list but im getting only the last mat no. details. I have tried hide and clear statements too but for me its not coming.

IF FNAM = 'WA_MARA-MATNR'.

    SELECT SINGLE * FROM MARA INTO WA_MARA WHERE MATNR = FVAL .

      WRITE:/ WA_MARA-MATNR, WA_MARA-MBRSH, WA_MARA-MTART, WA_MARA-MATKL, WA_MARA-MEINS, WA_MARA-ERSDA, WA_MARA-ERNAM.

  

  ELSEIF FNAM = ''.

...

...

... 

...

...


  ENDIF.

ENDFORM.

O/P:

Basic list:

23                 ROH  EA  1

38                 HALB PC  M

43                 HAWA HR  1

58                 HIBE PC  M

59                 HIBE PC  M

68                 FHMI PC  A

78                 DIEN PC  M

88                 FERT PC  M

89                 FERT PC  M

98                 HALB PC  M

Secondary list if mat no.

98                 M HALB 002       PC

only last value is coming

1 ACCEPTED SOLUTION
Read only

0 Likes
1,001

Hello Vishal n Aditya,

Thank you for your response. This is the code

Data: it_mara type table of mara,

      wa_mara type mara.

Data: it_makt type table of makt,

      wa_makt type makt.

Data: fnam(30), fval(50).

select-options: s_matnr for wa_mara-matnr.

initialization.

at selection-screen.

 

start-of-selection.

 

  at line-selection.

    perform DISPLAY_SECONDARYLIST.

form get_details.

   select * from mara into table it_mara where matnr in s_matnr.

     loop at it_mara into wa_mara.

       write: / wa_mara-matnr, wa_mara-mtart, wa_mara-meins, wa_mara-mbrsh.

       endloop.

       endform.

form DISPLAY_SECONDARYLIST.

   get cursor field fnam value fval.

   condense FNAM.

   condense FVAL.

if FNAM = 'WA_MARA-MATNR'.

SELECT SINGLE * FROM MARA INTO WA_MARA WHERE MATNR = FVAL .

      WRITE:/ WA_MARA-MATNR, WA_MARA-MBRSH, WA_MARA-MTART, WA_MARA-MATKL, WA_MARA-MEINS, WA_MARA-ERSDA, WA_MARA-ERNAM.

  ELSEIF FNAM = 'WA_MARA-MTART'.

    SELECT * FROM MARA INTO TABLE IT_MARA UP TO 50 ROWS WHERE MTART = FVAL.

    LOOP AT IT_MARA INTO WA_MARA.

      WRITE:/ WA_MARA-MATNR, WA_MARA-MTART, WA_MARA-MATKL.

    ENDLOOP.

  ENDIF.

ENDFORM.

Thanks,

Viky

6 REPLIES 6
Read only

Hvshal4u
Active Participant
0 Likes
1,001

Hi Vivek,

Can you paste your full code.

Regards,

Vishal

Read only

Former Member
0 Likes
1,001

Hi,

GET CURSOR FIELD <fnam> VALUE <fval>. " this is your statement

CONDENSE FNAM.

CONDENSE FVAL.

have you declared FNAM and FVAL properly..

and condense them as well after assigning value to them..

please paste your code for better understanding.

thanks!!

Read only

0 Likes
1,002

Hello Vishal n Aditya,

Thank you for your response. This is the code

Data: it_mara type table of mara,

      wa_mara type mara.

Data: it_makt type table of makt,

      wa_makt type makt.

Data: fnam(30), fval(50).

select-options: s_matnr for wa_mara-matnr.

initialization.

at selection-screen.

 

start-of-selection.

 

  at line-selection.

    perform DISPLAY_SECONDARYLIST.

form get_details.

   select * from mara into table it_mara where matnr in s_matnr.

     loop at it_mara into wa_mara.

       write: / wa_mara-matnr, wa_mara-mtart, wa_mara-meins, wa_mara-mbrsh.

       endloop.

       endform.

form DISPLAY_SECONDARYLIST.

   get cursor field fnam value fval.

   condense FNAM.

   condense FVAL.

if FNAM = 'WA_MARA-MATNR'.

SELECT SINGLE * FROM MARA INTO WA_MARA WHERE MATNR = FVAL .

      WRITE:/ WA_MARA-MATNR, WA_MARA-MBRSH, WA_MARA-MTART, WA_MARA-MATKL, WA_MARA-MEINS, WA_MARA-ERSDA, WA_MARA-ERNAM.

  ELSEIF FNAM = 'WA_MARA-MTART'.

    SELECT * FROM MARA INTO TABLE IT_MARA UP TO 50 ROWS WHERE MTART = FVAL.

    LOOP AT IT_MARA INTO WA_MARA.

      WRITE:/ WA_MARA-MATNR, WA_MARA-MTART, WA_MARA-MATKL.

    ENDLOOP.

  ENDIF.

ENDFORM.

Thanks,

Viky

Read only

0 Likes
1,001

Hi Vivek,

When your get_details form gets called ????

I want to point two issues in you code.


1st one is apply the conversion routine to the FVAL. as it is holding the value which is in external formt. So here your SELECT statement is getting failed at the same time you are clearing the workarea which is " WA_MARA" holding the value i.e the last record of the loop which is executed to show the basic list. So it is displaying the last record of the basic list.

2nd one is declare one more variable of type MATNR and pass this to the select statement of the secodary list.


Modify your code as below :

  data lv_matnr type matnr. "local variable of type MATNR.

  GET CURSOR FIELD fnam VALUE fval.

  CONDENSE fnam.

  CONDENSE fval.

  clear: wa_mara,lv_matnr.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' " apply conversion routine

    EXPORTING

      input         = fval

   IMPORTING

     OUTPUT        = lv_matnr

            .

  IF fnam = 'WA_MARA-MATNR'.

    SELECT SINGLE * FROM mara INTO wa_mara WHERE matnr = lv_matnr .

    WRITE:/ wa_mara-matnr, wa_mara-mbrsh, wa_mara-mtart, wa_mara-matkl, wa_mara-meins, wa_mara-ersda, wa_mara-ernam.

endif


Regards,

Vishal


Read only

VenkatRamesh_V
Active Contributor
0 Likes
1,001

Hi Vivek.

you are using same work area.

Try to validate using.

if FNAM = 'WA_MARA-MATNR'.

SELECT SINGLE * FROM MARA INTO WA_MARA WHERE MATNR = FVAL .

if sy-subrc is initial.

      WRITE:/ WA_MARA-MATNR, WA_MARA-MBRSH, WA_MARA-MTART, WA_MARA-MATKL, WA_MARA-MEINS, WA_MARA-ERSDA, WA_MARA-ERNAM.

endif.

Hope it helpful,

Regards,

Venkat.

Read only

0 Likes
1,001

Thanks everyone.