‎2006 Aug 23 1:51 PM
Hi,
hope anybody can help.
My programm is type module pool. On the left side is a ALV Treecontrol with many entries for subreports. The subreports defined as subscreen and displayed on the right sight of my dynpro.
Each subreport has one selection screen. Our users want to save variants like the one in normal reports.
For this requirment we tried to "copy" the sap solution for saving variants.
And here is our problem. Saving and changing the variants is no problem.
After loading the variants we copy the values in the parameters and select-options fields. But not all values where copied correct into the fields.
Example : We have the field impersonal account. In database the value is saved like 0012345678. On select-options-low the value is displayed with 12345678.
But after loading our variant, sap search the database with 12345678 and the result is empty. If sap search with 0012345678 the result is 234 entries.
If the puts the value for impersonal account manual into select-options field, sap search with 0012345678.
Here is our coding :
Loading the Variant :
FORM load_variant.
DATA: lv_variant TYPE rsvar-variant.
IF NOT gv_variant IS INITIAL.
lv_variant = gv_variant.
ELSE.
CALL FUNCTION 'RS_VARIANT_CATALOG'
EXPORTING
report = sy-cprog
* NEW_TITLE = ' '
dynnr = gv_dynpro
* INTERNAL_CALL = ' '
* MASKED = 'X'
* VARIANT = ' '
* POP_UP = ' '
IMPORTING
sel_variant = lv_variant
* SEL_VARIANT_TEXT =
* TABLES
* BELONGING_DYNNR =
EXCEPTIONS
no_report = 1
report_not_existent = 2
report_not_supplied = 3
no_variants = 4
no_variant_selected = 5
variant_not_existent = 6
OTHERS = 7
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
CALL FUNCTION 'RS_VARIANT_CONTENTS'
EXPORTING
report = sy-cprog
variant = lv_variant
move_or_write = 'W'
* NO_IMPORT = ' '
* EXECUTE_DIRECT = ' '
* IMPORTING
* SP =
TABLES
* L_PARAMS =
* L_PARAMS_NONV =
* L_SELOP =
* L_SELOP_NONV =
valutab = gt_params
* OBJECTS =
* FREE_SELECTIONS_DESC =
* FREE_SELECTIONS_VALUE =
EXCEPTIONS
variant_non_existent = 1
variant_obsolete = 2
report_not_existent = 3
OTHERS = 4
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
PERFORM get_screenvalues.
ENDIF.
CLEAR: lv_variant, wa_params.
REFRESH: gt_params.
ENDFORM.
Insert the variant values into the selection screen:
FORM get_screenvalues.
DATA: lv_sel(9) TYPE c,
lv_selname(10) TYPE c.
DATA: lt_params TYPE TABLE OF rsparams.
FIELD-SYMBOLS: <table> TYPE ANY TABLE,
<wa> TYPE ANY,
<field> TYPE ANY.
DELETE gt_params WHERE low IS initial.
lt_params[] = gt_params[].
SORT lt_params BY selname.
DELETE ADJACENT DUPLICATES FROM lt_params COMPARING selname.
* Suchstring für "Loop at screen" erstellen
CONCATENATE '++' gv_dynpro_sel '++*' INTO lv_sel.
* Leeren der Dynprofelder. Unterscheiden ob Parameter oder
* Select-Options
LOOP AT SCREEN.
IF screen-name CP lv_sel.
IF screen-group3 = 'PAR'.
lv_selname = screen-name+0(8).
ASSIGN (lv_selname) TO <wa>.
CLEAR <wa>.
ELSE.
CONCATENATE screen-name+0(8) '[]' INTO lv_selname.
ASSIGN (lv_selname) TO <wa>.
ASSIGN (lv_selname) TO <table>.
CLEAR <wa>.
REFRESH <table>.
ENDIF.
UNASSIGN: <wa>, <table>.
MODIFY SCREEN.
CLEAR lv_selname.
ENDIF.
ENDLOOP.
* Suchstring Parameter in der Parametertabelle
CLEAR lv_sel.
CONCATENATE '++' gv_dynpro_sel '++' INTO lv_sel.
* Wieder Unterscheidung von Parameter und Select-Options
LOOP AT gt_params INTO wa_params WHERE selname CP lv_sel.
IF wa_params-kind = 'P'.
* Wenn ein Datum im Wertefeld, dann wird dieses je nach Länge
* umgebaut.
IF wa_params-low CP '++.++++'.
CONCATENATE wa_params-low+3(4) '.' wa_params-low+0(2)
INTO wa_params-low.
ELSEIF wa_params-low CP '++.++.++++'.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = wa_params-low
IMPORTING
date_internal = wa_params-low.
ENDIF.
ASSIGN (wa_params-selname) TO <wa>.
<wa> = wa_params-low.
ELSEIF wa_params-kind = 'S'.
CONCATENATE wa_params-selname '[]' INTO lv_selname.
ASSIGN (lv_selname) TO <table>.
ASSIGN (wa_params-selname) TO <wa>.
CLEAR <wa>.
ASSIGN COMPONENT 'OPTION' OF STRUCTURE <wa>
TO <field>.
<field> = wa_params-option.
UNASSIGN <field>.
ASSIGN COMPONENT 'SIGN' OF STRUCTURE <wa>
TO <field>.
<field> = wa_params-sign.
UNASSIGN <field>.
ASSIGN COMPONENT 'LOW' OF STRUCTURE <wa>
TO <field>.
IF wa_params-low CP '++.++++'.
CONCATENATE wa_params-low+3(4) '.' wa_params-low+0(2)
INTO wa_params-low.
ELSEIF wa_params-low CP '++.++.++++'.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = wa_params-low
IMPORTING
date_internal = <field>.
ELSE.
<field> = wa_params-low.
ENDIF.
UNASSIGN <field>.
* Wenn es ein Range ist, dann wird auch das zweite Feld umgesetzt.
IF wa_params-option = 'BT'.
ASSIGN COMPONENT 'HIGH' OF STRUCTURE <wa>
TO <field>.
IF wa_params-low CP '++.++++'.
CONCATENATE wa_params-low+3(4) '.' wa_params-low+0(2)
INTO wa_params-low.
ELSEIF wa_params-high CP '++.++.++++'.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = wa_params-high
IMPORTING
date_internal = <field>.
ELSE.
<field> = wa_params-high.
ENDIF.
UNASSIGN <field>.
ENDIF.
INSERT <wa> INTO TABLE <table>.
ENDIF.
UNASSIGN: <wa>, <table>.
CLEAR: wa_params.
ENDLOOP.
CLEAR: lv_sel, lv_selname.
CALL METHOD cl_gui_cfw=>flush.
I think, that sap not run the conversion exits after loading our variants. Any ideas?
Regards,
Anton
‎2006 Aug 23 1:57 PM
Go to the Domain level of the impersonal account field and see if there are any conversion routines available.
Or let us know what is the declaration for the impersonal account in your program.
Regards,
ravi
‎2006 Aug 23 3:59 PM
Hi,
conversion routines is ALPHA. The declaration is mseg-sakto.
Applaying the conversion routines is my workaround. I coded
the program very dynamic because we added every month about one or two reports.
I don`t want to applay several conversion exits for different select-options.
Regards,
Anton
Message was edited by: Anton Hartl
‎2006 Aug 23 4:09 PM
You have to use CONVERSION_EXIT_ALPHA_INPUT(External to internal) function module for all those selec-options which have alpha conv routine.
Regards,
ravi
(CONVERSION_EXIT_ALPHA_OUTPUT for internal to external)
‎2006 Aug 23 4:47 PM
Thx for your reply.
That's my workaround. But i want sap to do the conversion automatically.
The program is coded very dynamic. When developer add some new subreports, they needn`t care about saving variants.
It's not very comfortable to start every conversion routines manual.
I don`t understand why sap starts the conversion automatic if the user insert the values manual, and don`t start the conversion when the values added by program.
Regards,
Anton
‎2006 Aug 23 2:05 PM
Hi,
Before applying the select statment apply conversion routinue on the field which you will be applying in select statement or if you attach the conversion routinue in the domain level .
Regards,
Raghav