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: 

Regarding sy-lilli, Get cursor line

Former Member
0 Kudos
206

Hi Folks,

I'm having some trouble with getting the cursor line in a search help selection.

This is my code:

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
       EXPORTING
            retfield        = 'XBLNR'
            dynpprog        = sy-repid
            dynpnr          = sy-dynnr
            dynprofield     = 'ITAB-FACTURA'
            window_title    = 'Facturas'
            value_org       = 'S'
       TABLES
            value_tab       = itab_bsik_v[]
            return_tab      = return_tab
       EXCEPTIONS
            parameter_error = 1
            no_values_found = 2
            OTHERS          = 3.
  IF sy-subrc = 0.
  ENDIF.

  GET CURSOR LINE l_linea.

  READ TABLE itab_bsik_v INDEX l_linea.

  DATA: l_stepl LIKE  sy-stepl,
         l_indx  LIKE  sy-stepl.
  DATA: dynpfields        LIKE dynpread OCCURS 5 WITH HEADER LINE.

* Adjust for scroling within table control
  CALL FUNCTION 'DYNP_GET_STEPL'
       IMPORTING
            povstepl        = l_stepl
       EXCEPTIONS
            stepl_not_found = 0
            OTHERS          = 0.

  l_indx = grid-top_line + l_stepl - 1.

  REFRESH dynpfields.
  CLEAR   dynpfields.
  dynpfields-fieldname  = 'ITAB-FACTURA'.
  dynpfields-fieldvalue = itab_bsik_v-xblnr.
  dynpfields-stepl      = l_stepl.
  APPEND dynpfields.
  dynpfields-fieldname  = 'ITAB-BUZEI'.
  dynpfields-fieldvalue = itab_bsik_v-buzei.
  dynpfields-stepl      = l_stepl.
  APPEND dynpfields.

  CALL FUNCTION 'DYNP_VALUES_UPDATE'
       EXPORTING
            dyname     = sy-repid  "Program name
            dynumb     = sy-dynnr  "Screen number
       TABLES
            dynpfields = dynpfields
       EXCEPTIONS
            OTHERS     = 0.

The internal table itab_bsik_v is filled with 10 records. So when user clicks on record 5, I would expect that l_linea gets 5 as cursor line, however I'm getting 1 always.

I tried changing the GET CURSOR LINE by sy-lilli but I'm not understanding really well the sy-lilli variable because when I click the first line of the search help result, I get a 4 as the index, and when I click in the last line I get 13.

If anyone could help me with this I really appreciate it.

Thanks for your help.

Regards,

Gilberto Li

1 ACCEPTED SOLUTION

former_member598013
Active Contributor
0 Kudos
156

Hi Gilberto,

Try to change one declaration. I guess It will work.


DATA: dynpfields        LIKE dynpread OCCURS 5 WITH HEADER LINE.

Change it to


DATA: dynpfields        LIKE dynpread OCCURS  0  WITH HEADER LINE.

&********Reward Point if helpful***********&

10 REPLIES 10

former_member598013
Active Contributor
0 Kudos
157

Hi Gilberto,

Try to change one declaration. I guess It will work.


DATA: dynpfields        LIKE dynpread OCCURS 5 WITH HEADER LINE.

Change it to


DATA: dynpfields        LIKE dynpread OCCURS  0  WITH HEADER LINE.

&********Reward Point if helpful***********&

Former Member
0 Kudos
156

Instead of using GET CURSOR LINE why not u use return_tab.

This int. table should contins data selected ny user during F4 help. I have done few changes in ur code. pl. check whether it works or not.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield = 'XBLNR'

dynpprog = sy-repid

dynpnr = sy-dynnr

dynprofield = 'ITAB-FACTURA'

window_title = 'Facturas'

value_org = 'S'

TABLES

value_tab = itab_bsik_v[]

return_tab = return_tab

EXCEPTIONS

parameter_error = 1

no_values_found = 2

OTHERS = 3.

IF sy-subrc = 0.

ENDIF.

    • GET CURSOR LINE l_linea.*

    • READ TABLE itab_bsik_v INDEX l_linea.*

read table return_tab into l_wa_return

with key fieldname = 'XBLNR'.

if sy-subrc eq 0.

l_XBLNR = l_wa_return-fieldval.

endif.

read table return_tab into l_wa_return

with key fieldname = 'BUZEI'.

if sy-subrc eq 0.

l_BUZEI = l_wa_return-fieldval.

endif.

DATA: l_stepl LIKE sy-stepl,

l_indx LIKE sy-stepl.

DATA: dynpfields LIKE dynpread OCCURS 5 WITH HEADER LINE.

  • Adjust for scroling within table control

CALL FUNCTION 'DYNP_GET_STEPL'

IMPORTING

povstepl = l_stepl

EXCEPTIONS

stepl_not_found = 0

OTHERS = 0.

l_indx = grid-top_line + l_stepl - 1.

REFRESH dynpfields.

CLEAR dynpfields.

dynpfields-fieldname = 'ITAB-FACTURA'.

dynpfields-fieldvalue = l_XBLNR.

dynpfields-stepl = l_stepl.

APPEND dynpfields.

dynpfields-fieldname = 'ITAB-BUZEI'.

dynpfields-fieldvalue = l_BUZEI.

dynpfields-stepl = l_stepl.

APPEND dynpfields.

CALL FUNCTION 'DYNP_VALUES_UPDATE'

EXPORTING

dyname = sy-repid "Program name

dynumb = sy-dynnr "Screen number

TABLES

dynpfields = dynpfields

EXCEPTIONS

OTHERS = 0.

former_member212653
Active Contributor
0 Kudos
156

why do you need the line no. Get the selected value from the RETURN table.

Check this out



CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
  EXPORTING
    retfield        = 'XBLNR'
    dynpprog        = sy-repid
    dynpnr          = sy-dynnr
    dynprofield     = 'ITAB-FACTURA'
    window_title    = 'Facturas'
    value_org       = 'S'
  TABLES
    value_tab       = itab_bsik_v[]
    return_tab      = return_tab
  EXCEPTIONS
    parameter_error = 1
    no_values_found = 2
    OTHERS          = 3.
IF sy-subrc = 0.
ENDIF.
DATA: l_wa_return TYPE ddshretval.
*GET CURSOR LINE l_linea.
READ TABLE return_tab INTO l_wa_return
INDEX 1.
IF sy-subrc = 0.
  READ TABLE itab_bsik_v WITH KEY
 (l_wa_return-fieldname) =
 l_wa_return-fieldval.
  IF sy-subrc = 0.

  ENDIF.
ENDIF.
DATA: l_stepl LIKE  sy-stepl,
       l_indx  LIKE  sy-stepl.
DATA: dynpfields        LIKE dynpread OCCURS 5 WITH HEADER LINE.

* Adjust for scroling within table control
CALL FUNCTION 'DYNP_GET_STEPL'
  IMPORTING
    povstepl        = l_stepl
  EXCEPTIONS
    stepl_not_found = 0
    OTHERS          = 0.

l_indx = grid-top_line + l_stepl - 1.

REFRESH dynpfields.
CLEAR   dynpfields.
dynpfields-fieldname  = 'ITAB-FACTURA'.
dynpfields-fieldvalue = itab_bsik_v-xblnr.
dynpfields-stepl      = l_stepl.
APPEND dynpfields.
dynpfields-fieldname  = 'ITAB-BUZEI'.
dynpfields-fieldvalue = itab_bsik_v-buzei.
dynpfields-stepl      = l_stepl.
APPEND dynpfields.

CALL FUNCTION 'DYNP_VALUES_UPDATE'
  EXPORTING
    dyname     = sy-repid  "Program name
    dynumb     = sy-dynnr  "Screen number
  TABLES
    dynpfields = dynpfields
  EXCEPTIONS
    OTHERS     = 0.



Former Member
0 Kudos
156

Hi all,

Thanks for your answers, but, I've checked the return_tab and this tab does not contain buzei field.

The fields are:

SHLPNAME

FIELDNAME

RECORDPOS

FIELDVAL

RETFIELD

Where the fieldval would be only XBLNR, and for one XBLNR I can get several BUZEI, thats why I can't get BUZEI from a SELECT to the database, I need it from the search help selection.

Hope you guys understand what I mean.

Regards,

Gilberto Li

0 Kudos
156

Hi u can get the field BUZEI in return_tab table. Pl. see this documentation (portion marked in bold)

Return the selected value

Description

The selected value is returned in table RETURN_TAB if it is not copied to screen fields in the module itself.

Caution: Despite being called with RETURN_TAB, up to Release 4.6B the help is started amodally as soon as the screen information DYNPPROG, DYNPNR and DYNPROFIELD is passed and the user has activated the ActiveX help. In this case you cannot be sure that the RETURN_TAB contains the selected lines of the hit list. In an amodal call, the function module terminates before the user has made his choice.

In most cases table RETURN_TAB has exactly one line containing the contents of the return column from the selected line of the hit list in field FIELDVAL.

If RETURN_TAB does not contain any lines, the user has terminated the selection.

If there are multiple return columns or if multiple selection was allowed, the table can contain more than one line.

If there is more than one return column, FIELDNAME specifies the column to which the value in FIELDVAL belongs. FIELDNAME corresponds to field FIELDNAME in table FIELD_TAB.

With multiple selection (more than one line of the hit list is selected), field RECORDPOS is used to number the lines, i.e. if three lines were selected, all the columns of the first selected line are numbered with RECORDPOS = 1, all the columns of the second line are numbered wiith RECORDPOS = 2, etc.

Field RETFIELD specifies the screen field belonging to the column if it is known. If there is only one return column, RETFIELD contains the field name passed in DYNPROFIELD.

Field SHLPNAME is not relevant for this module.

Regards,

Joy.

0 Kudos
156

Hi Joy,

In what version is that help from?

I am working at 4.6C. And I didn't saw that 😕

Regards,

Gilberto Li

0 Kudos
156

This help is in ECC 5.0 version.....

Regards,

Joy.

Former Member
0 Kudos
156

Have you tried moving the call to DYNP_GET_STEPL up before the F4IF call, and passing the result to the F4IF call in the STEPL parameter?.. there's an example in function module CATS_F4_HELP_AWART that might help - or do a where-used on DYNP_GET_STEPL to see where else you can crib some code from.

Jonathan

0 Kudos
156

Hi Jonathan,

The function DYNP_GET_STEPL defines the current step loop line from which the F4 or F1 help was called. And what I need is the current step loop line from the search help, not from where it was called.

Thanks.

Regards,

Gilberto Li

Former Member
0 Kudos
156

Thanks everyone.

I have solved the problem.

Regards,

Gilberto Li