2014 Dec 03 4:11 AM
Hello All,
I have 3 fields in my selection screen.
I have a requirement to focus the cursor on the field when a wrong entry is done and error message is displayed.
I am right now trying the below source but in here the focus still remains on the first field even if there is error in second.
I am doing it in Start-of-selection. I tried using At Selection-screen on fieldname but doesnt seem to work.
Any ideas on how to solve this?
START-OF-SELECTION.
SELECT SINGLE * FROM ewoss WHERE dummykey = space.
IF sy-subrc = 0.
IF ( p_ipaddr <> space ) OR ( p_instno <> space ).
IF p_dest = space.
SET CURSOR FIELD 'P_DEST'.
MESSAGE 'サーバ名を指定してください' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ELSE.
EWOSS-SR1NAME = p_dest.
ENDIF.
ENDIF.
IF ( p_dest <> space ) OR ( p_instno <> space ).
IF ( p_ipaddr CN '0123456789. ' ) OR ( p_ipaddr = space ).
SET CURSOR FIELD 'P_IPADDR'.
MESSAGE 'IPアドレスを指定してください' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ELSE.
EWOSS-SR1IP = p_ipaddr.
ENDIF.
ENDIF.
IF ( p_dest <> space ) OR ( p_ipaddr <> space ).
IF ( p_instno CN '0123456789' ).
SET CURSOR FIELD 'P_INSTNO'.
MESSAGE 'インスタンス番号を指定してください' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ELSE.
EWOSS-SR1INST = p_instno.
ENDIF.
ENDIF.
ENDIF.
Thanks.
2014 Dec 05 12:00 AM
Hi Gita,
Was this issue resolved? If not let me know and I can help.
Thanks,
Naveen
2014 Dec 03 4:36 AM
How do I check if sy-subrc is 0 in case of the At Selection-screen on fieldname since the select is common for all 3 fields.
Any ideas please?
2014 Dec 03 4:37 AM
hi
before set cursor use get cursor
GET CURSOR FIELD cur_field.
cur_field = 'P_DEST'.
SET CURSOR FIELD cur_field.
regards
laxman
2014 Dec 03 4:48 AM
Thank you Laxman, i modified it as below but still doesnt seem to work.
Did it work for you?
DATA: cur_field TYPE C.
IF ( p_ipaddr CN '0123456789. ' ) OR ( p_ipaddr = space ).
GET CURSOR FIELD cur_field.
cur_field = 'P_IPADDR'.
SET CURSOR FIELD cur_field.
MESSAGE 'IPアドレスを指定してください' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ELSE.
EWOSS-SR1IP = p_ipaddr.
ENDIF.
Thanks.
2014 Dec 03 5:05 AM
Hi Gita,
Refer below code. You are trying to set cursor in Start-of-selection event, change it to Initialization event and then check.
SELECTION-SCREEN BEGIN OF BLOCK b.
PARAMETERS:
matnr LIKE makt-matnr,
maktx LIKE makt-maktx.
SELECTION-SCREEN END OF BLOCK b.
AT SELECTION-SCREEN ON BLOCK b .
INITIALIZATION.
SET CURSOR FIELD 'MAKTX' .
2014 Dec 03 5:21 AM
Thank you Archana, But if i put it in initialization, it will by default place the cursor on the last initialized field (since all my fields are blank during generation).
I modified my source as below, but doesnt seem to work. When I execute it is by default pointing to Instance no and displaying the error message. ?!!
AT SELECTION-SCREEN ON BLOCK Router.
INITIALIZATION.
Router = 'SAPルータ'.
Destin = '名称'.
Ipadd = 'IP アドレス'.
Instno = 'Instance no.'.
SELECT SINGLE * FROM ewoss WHERE dummykey = space.
IF sy-subrc = 0.
IF p_dest = space.
SET CURSOR FIELD 'P_DEST'.
MESSAGE 'サーバ名を指定してください' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ELSE.
EWOSS-SR1NAME = p_dest.
ENDIF.
IF ( p_ipaddr CN '0123456789. ' ) OR ( p_ipaddr = space ).
SET CURSOR FIELD 'P_IPADDR'.
MESSAGE 'IPアドレスを指定してください' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ELSE.
EWOSS-SR1IP = p_ipaddr.
ENDIF.
IF ( p_instno CN '0123456789' ).
SET CURSOR FIELD 'P_INSTNO'.
MESSAGE 'インスタンス番号を指定してください' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ELSE.
EWOSS-SR1INST = p_instno.
ENDIF.
ENDIF.
2014 Dec 03 5:37 AM
2014 Dec 03 5:42 AM
Like I already said I have tried that as well. Doesnt seem to work as expected. I am pasting my current full source code here. If it is possible by you, can you please try at your end and see if it works for you?
Thanks.
*&---------------------------------------------------------------------*
*& Report ZGUITEST_ROUTER
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZGUITEST_ROUTER NO STANDARD PAGE HEADING MESSAGE-ID s1.
TABLES: EWOSS.
DATA: L_EV_RFC_OPTIONS LIKE RFCDES-RFCOPTIONS.
DATA:
d_gateway1ip LIKE rfcopt-rfchost ,
d_gateway1instanz LIKE rfcopt-rfcservice ,
d_gateway2ip LIKE rfcopt-rfchost ,
d_gateway2instanz LIKE rfcopt-rfcservice ,
d_sapservxip LIKE rfcopt-rfchost ,
d_sapservxinstanz LIKE rfcopt-rfcservice ,
d_oss_servname LIKE rfcopt-rfchost ,
d_oss_servinstanz LIKE rfcopt-rfcservice .
SELECTION-SCREEN BEGIN OF BLOCK Router WITH FRAME TITLE Router.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(15) Destin FOR FIELD p_dest.
PARAMETERS: p_dest TYPE EWOSS-SR1NAME.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(15) Ipadd FOR FIELD p_ipaddr.
PARAMETERS: p_ipaddr TYPE EWOSS-SR1IP.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(15) Instno FOR FIELD p_instno.
PARAMETERS: p_instno TYPE EWOSS-SR1INST.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK Router.
INITIALIZATION.
Router = 'SAPルータ'.
Destin = '名称'.
Ipadd = 'IP アドレス'.
Instno = 'Instance no.'.
START-OF-SELECTION.
SELECT SINGLE * FROM ewoss WHERE dummykey = space.
IF sy-subrc = 0.
IF p_dest = space.
SET CURSOR FIELD 'P_DEST'.
MESSAGE 'サーバ名を指定してください' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ELSE.
EWOSS-SR1NAME = p_dest.
ENDIF.
IF ( p_ipaddr CN '0123456789. ' ) OR ( p_ipaddr = space ).
SET CURSOR FIELD 'P_IPADDR'.
MESSAGE 'IPアドレスを指定してください' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ELSE.
EWOSS-SR1IP = p_ipaddr.
ENDIF.
IF ( p_instno CN '0123456789' ).
SET CURSOR FIELD 'P_INSTNO'.
MESSAGE 'インスタンス番号を指定してください' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ELSE.
EWOSS-SR1INST = p_instno.
ENDIF.
ENDIF.
IF EWOSS IS NOT INITIAL.
MODIFY ewoss.
IF SY-SUBRC <> 0.
WRITE: 'NG'.
ELSE.
d_gateway1ip = EWOSS-SR1IP.
d_gateway1instanz = EWOSS-SR1INST.
d_gateway2ip = EWOSS-SR2IP .
d_gateway2instanz = EWOSS-SR2INST.
d_sapservxip = EWOSS-SAPXIP.
d_sapservxinstanz = EWOSS-SAPXINST.
d_oss_servname = EWOSS-OSSNAME.
d_oss_servinstanz = EWOSS-OSSINST.
* Function module to update the RFC destination
CALL FUNCTION 'EPS_UPDATE_RFC_DESTINATION'
EXPORTING
IV_ROUTER_1 = d_gateway1ip
IV_SERVICE_1 = d_gateway1instanz
IV_ROUTER_2 = d_gateway2ip
IV_SERVICE_2 = d_gateway2instanz
IV_ROUTER_SAP = d_sapservxip
IV_SERVICE_SAP = d_sapservxinstanz
IV_HOST_OSS = d_oss_servname
IV_SERVICE_OSS = d_oss_servinstanz
IMPORTING
EV_RFC_OPTIONS = L_EV_RFC_OPTIONS
EXCEPTIONS
ROUTER_PATH_TOO_LONG = 1
INVALID_ARGUMENTS = 2
UPDATE_FAILED = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
WRITE: 'NG'.
ELSE.
WRITE: 'OK'.
ENDIF.
ENDIF.
ELSE.
WRITE: 'NG'.
ENDIF.
END-OF-SELECTION.
2014 Dec 03 6:18 AM
2014 Dec 03 7:11 AM
Hi,
This functionality can be obtained by using AT SELECTION-SCREEN ON fieldname event where fieldname is the name of the field which you want to be focused after error.
e.g :
PARAMETERS p_abc TYPE VBELN.
AT SELECTION-SCREEN ON p_abc.
IF p_abc IS INITIAL.
MESSAGE 'Please fill the required fields' TYPE 'E'.
ENDIF.
So, after the error message, only this field will be left enabled for input.
Regards,
Ashish
2014 Dec 03 7:20 AM
Thank you Ashish.
In my case there are 3 validations which I am doing based on the Select * query.
Now, where will I insert my At Selection-screen on field?
Supposing I do At selection-screen on field 3 times on all my 3 fields, where should i place it in my code so that it works? (sorry i tried a few times already and did not work for me)
Can you help out please?
Thanks.
2014 Dec 03 7:33 AM
Hi,
After an error message the only field which will be left enabled is the one for which the event is.
e.g AT SELECTION-SCREEN ON p_abc.
So, if a code with an error message is written in this even then only this field i.e p_abc will be left enabled on the screen and rest all fields will be disabled.
Therefore, in this particular event you should write the code relevant for validation of this field only. Because if validation code for another field is written here then it will be a waste as that field will get disabled after an error message.
Hence, in each AT SELECTION-SCREEN ON event write validation code for the field for which the event is running.
If you want to keep multiple fields enabled after an error message then keep them in a block and run event for this block
e.g
SELECTION-SCREEN BEGIN OF BLOCK xyz.
PARAMETERS : p_abc TYPE C,
p_pqr TYPE I,
p_aaa TYPE STRING.
SELECTION-SCREEN END OF BLOCK xyz.
AT SELECTION-SCREEN ON BLOCK xyz.
"validation code for all 3 fields
If an error message is given in this section then all the fields in the block xyz will be left enabled while all others will be disabled.
Hope it clears your doubt about the event functionality.
Regards,
Ashish
2014 Dec 03 7:49 AM
Hi Gita,
Put below code in Initialization event and then check, it works.
INITIALIZATION.
router = 'SAPルータ'.
destin = '名称'.
ipadd = 'IP アドレス'.
instno = 'Instance no.'.
SELECT SINGLE * FROM ewoss WHERE dummykey = space.
IF sy-subrc = 0.
IF p_dest = space.
SET CURSOR FIELD 'P_DEST'.
MESSAGE 'サーバ名を指定してください' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ELSE.
ewoss-sr1name = p_dest.
ENDIF.
IF ( p_ipaddr CN '0123456789. ' ) OR ( p_ipaddr = space ).
SET CURSOR FIELD 'P_IPADDR'.
MESSAGE 'IPアドレスを指定してください' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ELSE.
ewoss-sr1ip = p_ipaddr.
ENDIF.
IF ( p_instno CN '0123456789' ).
SET CURSOR FIELD 'P_INSTNO'.
MESSAGE 'インスタンス番号を指定してください' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ELSE.
ewoss-sr1inst = p_instno.
ENDIF.
ENDIF.
2014 Dec 03 7:53 AM
Thank you Ashish. Thank you for the explanation.
My requirement is to keep all the fields enabled and I want my cursor focus on the erraneous field.
For which I am using SET CURSOR FIELD command.
Tried enclosing the validations inside AT SELECTION SCREEN ON BLOCK aaa but wouldnt work either way.
Any clues?
Thanks.
2014 Dec 03 8:07 AM
Hi,
Write your code in this way :
AT SELECTION-SCREEN ON p_dest.
if p_ipaddr is not initial OR p_instno is not initial.
if p_dest is initial.
message 'Please fill the required field' TYPE 'E'.
else.
ewoss-sr1name = p_dest.
endif.
endif.
AT SELECTION-SCREEN ON p_ipaddr.
if p_dest is not initial or p_instno is not initial.
if p_ipaddr CN '012346789' or p_ipaddr is initial.
message 'Error message' TYPE 'E'.
else.
ewoss-sr1ip = p_ipaddr.
endif.
endif.
AT SELECTION-SCREEN ON p_instno.
if p_dest is not initial or p_ipaddr is not initial.
if p_instno CN '0123456789'.
message 'Error message' TYPE 'E'.
else.
ewoss-sr1inst = p_instno.
endif.
endif.
2014 Dec 03 8:19 AM
Thank you Ashish.
This disables the fields other than the erraneous one and even after providing the correct input it still shows Error message. Did this work for you?
BR,
Gita
2014 Dec 03 10:54 AM
Hi,
Please debug and check if the if conditions are satisfying correctly, change them as required.
Regards,
Ashish
2014 Dec 03 8:26 AM
Hi Gita,
Hope it helpful.
Try this code.
AT SELECTION-SCREEN.
DATA: fname(30),
fval(30).
GET CURSOR field fname value fval.
CASE fname.
WHEN 'P_DEST'.
IF fval IS INITIAL.
MESSAGE 'Enter the p_dest values' type 'S' DISPLAY LIKE 'E'.
STOP.
ENDIF.
WHEN 'P_IPADDR'.
IF fval IS INITIAL.
MESSAGE 'Enter the P_IPADDR values' type 'S' DISPLAY LIKE 'E'.
STOP.
ENDIF.
WHEN 'P_INSTNO'.
IF fval IS INITIAL.
MESSAGE 'Enter the P_INSTNO values' type 'S' DISPLAY LIKE 'E'.
STOP.
ENDIF.
ENDCASE.
Regards,
Venkat.
2014 Dec 05 2:28 AM
Thank you Venkat. The 'GET CURSOR field fname value fval' statement retrieves the field in which the cursor is last placed and hence it necessarily goes to 'P_INSTNO' since thats the last field I enter. How to do get cursor for the erraneous field? Only then I assume it will work.
2014 Dec 05 7:50 AM
Hi Gita,
Hope i understand, change the value condition to be not initial.
IF fval IS NOT INITIAL.
MESSAGE 'Enter the P_INSTNO values' type 'S' DISPLAY LIKE 'E'.
STOP.
ENDIF.
Regards,
Venkat.
2014 Dec 05 12:00 AM
Hi Gita,
Was this issue resolved? If not let me know and I can help.
Thanks,
Naveen
2014 Dec 05 2:28 AM
No Naveen, this hasn't been resolved yet. Any help would be highly appreciated. Thanks.
2014 Dec 05 2:34 AM
Hi Gita,
Below example code will work for you. I tried and it does work and it sets the cursor in field where there is an error:
PARAMETERS : p_matnr TYPE mara-matnr,
p_mtart TYPE mara-mtart,
p_werks TYPE marc-werks.
DATA : lv_mtart TYPE mara-mtart,
lv_matnr TYPE mara-matnr,
lv_werks TYPE t001w-werks.
AT SELECTION-SCREEN OUTPUT.
IF NOT p_mtart IS INITIAL.
SELECT SINGLE mtart FROM t134 INTO lv_mtart WHERE mtart = p_mtart.
IF NOT sy-subrc IS INITIAL.
SET CURSOR FIELD 'P_MTART'.
MESSAGE 'Material type invalid' TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.
ENDIF.
IF NOT p_matnr IS INITIAL.
SELECT SINGLE matnr FROM mara INTO lv_matnr WHERE matnr = p_matnr.
IF NOT sy-subrc IS INITIAL.
SET CURSOR FIELD 'P_MATNR'.
MESSAGE 'Material invalid' TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.
ENDIF.
IF NOT p_werks IS INITIAL.
SELECT SINGLE werks FROM t001w INTO lv_werks WHERE werks = p_werks.
IF NOT sy-subrc IS INITIAL.
SET CURSOR FIELD 'P_WERKS'.
MESSAGE 'Plant invalid' TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.
ENDIF.
You can modify the above code as required for you and it should work.
Thanks,
Naveen
2014 Dec 05 2:43 AM
Hi Gita,
I have modified your code and I think in the check for parameter P_INSTNO you have missed a space. could you try below code and see if it works:
TABLES: EWOSS.
DATA: L_EV_RFC_OPTIONS LIKE RFCDES-RFCOPTIONS.
DATA:
d_gateway1ip LIKE rfcopt-rfchost ,
d_gateway1instanz LIKE rfcopt-rfcservice ,
d_gateway2ip LIKE rfcopt-rfchost ,
d_gateway2instanz LIKE rfcopt-rfcservice ,
d_sapservxip LIKE rfcopt-rfchost ,
d_sapservxinstanz LIKE rfcopt-rfcservice ,
d_oss_servname LIKE rfcopt-rfchost ,
d_oss_servinstanz LIKE rfcopt-rfcservice .
SELECTION-SCREEN BEGIN OF BLOCK Router WITH FRAME TITLE Router.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(15) Destin FOR FIELD p_dest.
PARAMETERS: p_dest TYPE EWOSS-SR1NAME.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(15) Ipadd FOR FIELD p_ipaddr.
PARAMETERS: p_ipaddr TYPE EWOSS-SR1IP.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(15) Instno FOR FIELD p_instno.
PARAMETERS: p_instno TYPE EWOSS-SR1INST.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK Router.
INITIALIZATION.
Router = 'SAPルータ'.
Destin = '名称'.
Ipadd = 'IP アドレス'.
Instno = 'Instance no.'.
AT SELECTION-SCREEN OUTPUT.
SELECT SINGLE * FROM ewoss WHERE dummykey = space.
IF sy-subrc = 0.
IF p_dest = space.
SET CURSOR FIELD 'P_DEST'.
MESSAGE 'サーバ名を指定してください' TYPE 'S' DISPLAY LIKE 'E'.
* LEAVE LIST-PROCESSING.
ELSE.
EWOSS-SR1NAME = p_dest.
ENDIF.
IF ( p_ipaddr CN '0123456789. ' ) OR ( p_ipaddr = space ).
SET CURSOR FIELD 'P_IPADDR'.
MESSAGE 'IPアドレスを指定してください' TYPE 'S' DISPLAY LIKE 'E'.
* LEAVE LIST-PROCESSING.
ELSE.
EWOSS-SR1IP = p_ipaddr.
ENDIF.
IF ( p_instno CN '0123456789 ' ).
SET CURSOR FIELD 'P_INSTNO'.
MESSAGE 'インスタンス番号を指定してください' TYPE 'S' DISPLAY LIKE 'E'.
* LEAVE LIST-PROCESSING.
ELSE.
EWOSS-SR1INST = p_instno.
ENDIF.
ENDIF.
IF EWOSS IS NOT INITIAL.
MODIFY ewoss.
IF SY-SUBRC <> 0.
WRITE: 'NG'.
ELSE.
d_gateway1ip = EWOSS-SR1IP.
d_gateway1instanz = EWOSS-SR1INST.
d_gateway2ip = EWOSS-SR2IP .
d_gateway2instanz = EWOSS-SR2INST.
d_sapservxip = EWOSS-SAPXIP.
d_sapservxinstanz = EWOSS-SAPXINST.
d_oss_servname = EWOSS-OSSNAME.
d_oss_servinstanz = EWOSS-OSSINST.
* Function module to update the RFC destination
CALL FUNCTION 'EPS_UPDATE_RFC_DESTINATION'
EXPORTING
IV_ROUTER_1 = d_gateway1ip
IV_SERVICE_1 = d_gateway1instanz
IV_ROUTER_2 = d_gateway2ip
IV_SERVICE_2 = d_gateway2instanz
IV_ROUTER_SAP = d_sapservxip
IV_SERVICE_SAP = d_sapservxinstanz
IV_HOST_OSS = d_oss_servname
IV_SERVICE_OSS = d_oss_servinstanz
IMPORTING
EV_RFC_OPTIONS = L_EV_RFC_OPTIONS
EXCEPTIONS
ROUTER_PATH_TOO_LONG = 1
INVALID_ARGUMENTS = 2
UPDATE_FAILED = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
WRITE: 'NG'.
ELSE.
WRITE: 'OK'.
ENDIF.
ENDIF.
ELSE.
WRITE: 'NG'.
ENDIF.
END-OF-SELECTION.
Thanks,
Naveen
2014 Dec 05 3:07 AM
Thank you Naveen, your code works perfectly. But in your case you are picking values from the table in your select stmt and assigning it to your param. But in my case, i am assigning (saving) the values entered by the user into the table. Since I am quite a novice to sql programming logic, i am clueless as to how to modify your code for my requirement. Tried a few times but wouldnt work for my requirement. Can i ask for your help in resolving this if you have a little free time?
Thanks!
2014 Dec 05 4:24 AM
Naveen, thank you for all the efforts you are taking to help me out on this issue.
I tried the above code but there seems to be a few problems here.
1. It does not display OK or NG bcos its in AT SELECTION-SCREEN OUTPUT. (which is why i chose to use Start-of-selection)
2. When I press execute, by default it shows the message under IP address, 'IPアドレスを指定してください'.
3. When I enter 11 in the instance number, it doesnt update the data in table first.
Any idea on how to rectify this?
2014 Dec 05 5:25 AM
Hi Gita,
I can give you a work around for this. try below: I have added a error variable GV_ERROR.
TABLES: ewoss.
DATA: l_ev_rfc_options LIKE rfcdes-rfcoptions.
DATA:
d_gateway1ip LIKE rfcopt-rfchost ,
d_gateway1instanz LIKE rfcopt-rfcservice ,
d_gateway2ip LIKE rfcopt-rfchost ,
d_gateway2instanz LIKE rfcopt-rfcservice ,
d_sapservxip LIKE rfcopt-rfchost ,
d_sapservxinstanz LIKE rfcopt-rfcservice ,
d_oss_servname LIKE rfcopt-rfchost ,
d_oss_servinstanz LIKE rfcopt-rfcservice ,
gv_error TYPE char1.
SELECTION-SCREEN BEGIN OF BLOCK router WITH FRAME TITLE router.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(15) destin FOR FIELD p_dest.
PARAMETERS: p_dest TYPE ewoss-sr1name.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(15) ipadd FOR FIELD p_ipaddr.
PARAMETERS: p_ipaddr TYPE ewoss-sr1ip.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(15) instno FOR FIELD p_instno.
PARAMETERS: p_instno TYPE ewoss-sr1inst.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK router.
INITIALIZATION.
router = 'SAPルータ'.
destin = '名称'.
ipadd = 'IP アドレス'.
instno = 'Instance no.'.
AT SELECTION-SCREEN OUTPUT.
SELECT SINGLE * FROM ewoss WHERE dummykey = space.
IF sy-subrc = 0.
IF p_dest = space.
SET CURSOR FIELD 'P_DEST'.
MESSAGE 'サーバ名を指定してください' TYPE 'S' DISPLAY LIKE 'E'.
gv_error = 'X'.
* LEAVE LIST-PROCESSING.
ELSE.
ewoss-sr1name = p_dest.
ENDIF.
IF ( p_ipaddr CN '0123456789. ' ) OR ( p_ipaddr = space ).
SET CURSOR FIELD 'P_IPADDR'.
MESSAGE 'IPアドレスを指定してください' TYPE 'S' DISPLAY LIKE 'E'.
gv_error = 'X'.
* LEAVE LIST-PROCESSING.
ELSE.
ewoss-sr1ip = p_ipaddr.
ENDIF.
IF ( p_instno CN '0123456789 ' ).
SET CURSOR FIELD 'P_INSTNO'.
MESSAGE 'インスタンス番号を指定してください' TYPE 'S' DISPLAY LIKE 'E'.
gv_error = 'X'.
* LEAVE LIST-PROCESSING.
ELSE.
ewoss-sr1inst = p_instno.
ENDIF.
ENDIF.
START-OF-SELECTION.
IF gv_error IS INITIAL.
IF ewoss IS NOT INITIAL.
MODIFY ewoss.
IF sy-subrc <> 0.
WRITE: 'NG'.
ELSE.
d_gateway1ip = ewoss-sr1ip.
d_gateway1instanz = ewoss-sr1inst.
d_gateway2ip = ewoss-sr2ip .
d_gateway2instanz = ewoss-sr2inst.
d_sapservxip = ewoss-sapxip.
d_sapservxinstanz = ewoss-sapxinst.
d_oss_servname = ewoss-ossname.
d_oss_servinstanz = ewoss-ossinst.
* Function module to update the RFC destination
CALL FUNCTION 'EPS_UPDATE_RFC_DESTINATION'
EXPORTING
iv_router_1 = d_gateway1ip
iv_service_1 = d_gateway1instanz
iv_router_2 = d_gateway2ip
iv_service_2 = d_gateway2instanz
iv_router_sap = d_sapservxip
iv_service_sap = d_sapservxinstanz
iv_host_oss = d_oss_servname
iv_service_oss = d_oss_servinstanz
IMPORTING
ev_rfc_options = l_ev_rfc_options
EXCEPTIONS
router_path_too_long = 1
invalid_arguments = 2
update_failed = 3
OTHERS = 4.
IF sy-subrc <> 0.
WRITE: 'NG'.
ELSE.
WRITE: 'OK'.
ENDIF.
ENDIF.
ELSE.
WRITE: 'NG'.
ENDIF.
ENDIF.
END-OF-SELECTION.
CLEAR gv_error.
Thanks,
Naveen
2014 Dec 05 6:06 AM
Did it work for you Naveen?
Somehow it doest work out as expected for me.
Thanks
2014 Dec 05 7:37 AM
HI Gita,
i got the output as OK. What did you get?
DId you copy the full code and try?
thanks,
naveen
2014 Dec 08 1:37 AM
Hi Gita,
Please try below code. Let me know if there is any issue.
TABLES: ewoss.
DATA: l_ev_rfc_options LIKE rfcdes-rfcoptions.
DATA:
d_gateway1ip LIKE rfcopt-rfchost ,
d_gateway1instanz LIKE rfcopt-rfcservice ,
d_gateway2ip LIKE rfcopt-rfchost ,
d_gateway2instanz LIKE rfcopt-rfcservice ,
d_sapservxip LIKE rfcopt-rfchost ,
d_sapservxinstanz LIKE rfcopt-rfcservice ,
d_oss_servname LIKE rfcopt-rfchost ,
d_oss_servinstanz LIKE rfcopt-rfcservice ,
gv_error TYPE char1.
SELECTION-SCREEN BEGIN OF BLOCK router WITH FRAME TITLE router.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(15) destin FOR FIELD p_dest.
PARAMETERS: p_dest TYPE ewoss-sr1name.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(15) ipadd FOR FIELD p_ipaddr.
PARAMETERS: p_ipaddr TYPE ewoss-sr1ip.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(15) instno FOR FIELD p_instno.
PARAMETERS: p_instno TYPE ewoss-sr1inst.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK router.
INITIALIZATION.
router = 'SAPルータ'.
destin = '名称'.
ipadd = 'IP アドレス'.
instno = 'Instance no.'.
AT SELECTION-SCREEN OUTPUT.
CLEAR gv_error.
PERFORM validate CHANGING gv_error.
START-OF-SELECTION.
CLEAR gv_error.
PERFORM validate CHANGING gv_error.
IF gv_error IS INITIAL.
IF ewoss IS NOT INITIAL.
MODIFY ewoss.
IF sy-subrc <> 0.
WRITE: 'NG'.
ELSE.
d_gateway1ip = ewoss-sr1ip.
d_gateway1instanz = ewoss-sr1inst.
d_gateway2ip = ewoss-sr2ip .
d_gateway2instanz = ewoss-sr2inst.
d_sapservxip = ewoss-sapxip.
d_sapservxinstanz = ewoss-sapxinst.
d_oss_servname = ewoss-ossname.
d_oss_servinstanz = ewoss-ossinst.
* Function module to update the RFC destination
CALL FUNCTION 'EPS_UPDATE_RFC_DESTINATION'
EXPORTING
iv_router_1 = d_gateway1ip
iv_service_1 = d_gateway1instanz
iv_router_2 = d_gateway2ip
iv_service_2 = d_gateway2instanz
iv_router_sap = d_sapservxip
iv_service_sap = d_sapservxinstanz
iv_host_oss = d_oss_servname
iv_service_oss = d_oss_servinstanz
IMPORTING
ev_rfc_options = l_ev_rfc_options
EXCEPTIONS
router_path_too_long = 1
invalid_arguments = 2
update_failed = 3
OTHERS = 4.
IF sy-subrc <> 0.
WRITE: 'NG'.
ELSE.
WRITE: 'OK'.
ENDIF.
ENDIF.
ELSE.
WRITE: 'NG'.
ENDIF.
ENDIF.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Form VALIDATE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM validate CHANGING cv_error TYPE char1 .
SELECT SINGLE * FROM ewoss WHERE dummykey = space.
IF sy-subrc = 0.
IF p_dest = space.
SET CURSOR FIELD 'P_DEST'.
MESSAGE 'サーバ名を指定してください' TYPE 'S' DISPLAY LIKE 'E'.
cv_error = 'X'.
* LEAVE LIST-PROCESSING.
ELSE.
ewoss-sr1name = p_dest.
ENDIF.
IF ( p_ipaddr CN '0123456789. ' ) OR ( p_ipaddr = space ).
SET CURSOR FIELD 'P_IPADDR'.
MESSAGE 'IPアドレスを指定してください' TYPE 'S' DISPLAY LIKE 'E'.
cv_error = 'X'.
* LEAVE LIST-PROCESSING.
ELSE.
ewoss-sr1ip = p_ipaddr.
ENDIF.
IF ( p_instno CN '0123456789 ' ).
SET CURSOR FIELD 'P_INSTNO'.
MESSAGE 'インスタンス番号を指定してください' TYPE 'S' DISPLAY LIKE 'E'.
cv_error = 'X'.
* LEAVE LIST-PROCESSING.
ELSE.
ewoss-sr1inst = p_instno.
ENDIF.
ENDIF.
ENDFORM. " VALIDATE
Thanks,
Naveen
2014 Dec 10 2:05 AM
Thank you Naveen, there are a few issues here.
1. First, the pgm displays error message immediately on executing for the first time.
2. When I enter wrong values for both IP address and Instance no., the cursor denotes the error of the last enterd field (in my case, it says 'Instance番号を指定してください'.
Did it not work that way for you?
Any ideas would be appreciated
Thanks again.
2014 Dec 10 2:15 AM
Hi Gita,
I have put a work around for the two points you have raised. Please try below code and let me know if any issues:
TABLES: ewoss.
DATA: l_ev_rfc_options LIKE rfcdes-rfcoptions.
DATA:
d_gateway1ip LIKE rfcopt-rfchost ,
d_gateway1instanz LIKE rfcopt-rfcservice ,
d_gateway2ip LIKE rfcopt-rfchost ,
d_gateway2instanz LIKE rfcopt-rfcservice ,
d_sapservxip LIKE rfcopt-rfchost ,
d_sapservxinstanz LIKE rfcopt-rfcservice ,
d_oss_servname LIKE rfcopt-rfchost ,
d_oss_servinstanz LIKE rfcopt-rfcservice ,
gv_error TYPE char1,
gv_val TYPE char1.
SELECTION-SCREEN BEGIN OF BLOCK router WITH FRAME TITLE router.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(15) destin FOR FIELD p_dest.
PARAMETERS: p_dest TYPE ewoss-sr1name.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(15) ipadd FOR FIELD p_ipaddr.
PARAMETERS: p_ipaddr TYPE ewoss-sr1ip.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(15) instno FOR FIELD p_instno.
PARAMETERS: p_instno TYPE ewoss-sr1inst.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK router.
INITIALIZATION.
router = 'SAPルータ'.
destin = '名称'.
ipadd = 'IP アドレス'.
instno = 'Instance no.'.
AT SELECTION-SCREEN OUTPUT.
CLEAR gv_error.
PERFORM validate CHANGING gv_error.
START-OF-SELECTION.
CLEAR gv_error.
PERFORM validate CHANGING gv_error.
IF gv_error IS INITIAL.
IF ewoss IS NOT INITIAL.
MODIFY ewoss.
IF sy-subrc <> 0.
WRITE: 'NG'.
ELSE.
d_gateway1ip = ewoss-sr1ip.
d_gateway1instanz = ewoss-sr1inst.
d_gateway2ip = ewoss-sr2ip .
d_gateway2instanz = ewoss-sr2inst.
d_sapservxip = ewoss-sapxip.
d_sapservxinstanz = ewoss-sapxinst.
d_oss_servname = ewoss-ossname.
d_oss_servinstanz = ewoss-ossinst.
* Function module to update the RFC destination
CALL FUNCTION 'EPS_UPDATE_RFC_DESTINATION'
EXPORTING
iv_router_1 = d_gateway1ip
iv_service_1 = d_gateway1instanz
iv_router_2 = d_gateway2ip
iv_service_2 = d_gateway2instanz
iv_router_sap = d_sapservxip
iv_service_sap = d_sapservxinstanz
iv_host_oss = d_oss_servname
iv_service_oss = d_oss_servinstanz
IMPORTING
ev_rfc_options = l_ev_rfc_options
EXCEPTIONS
router_path_too_long = 1
invalid_arguments = 2
update_failed = 3
OTHERS = 4.
IF sy-subrc <> 0.
WRITE: 'NG'.
ELSE.
WRITE: 'OK'.
ENDIF.
ENDIF.
ELSE.
WRITE: 'NG'.
ENDIF.
ENDIF.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Form VALIDATE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM validate CHANGING cv_error TYPE char1 .
SELECT SINGLE * FROM ewoss WHERE dummykey = space.
IF sy-subrc = 0 AND gv_val = 'X'.
IF p_dest = space.
SET CURSOR FIELD 'P_DEST'.
MESSAGE 'destサーバ名を指定してください' TYPE 'S' DISPLAY LIKE 'E'.
cv_error = 'X'.
EXIT.
* LEAVE LIST-PROCESSING.
ELSE.
ewoss-sr1name = p_dest.
ENDIF.
IF ( p_ipaddr CN '0123456789. ' ) OR ( p_ipaddr = space ).
SET CURSOR FIELD 'P_IPADDR'.
MESSAGE 'IPアドレスを指定してください' TYPE 'S' DISPLAY LIKE 'E'.
cv_error = 'X'.
EXIT.
* LEAVE LIST-PROCESSING.
ELSE.
ewoss-sr1ip = p_ipaddr.
ENDIF.
IF ( p_instno CN '0123456789 ' ).
SET CURSOR FIELD 'P_INSTNO'.
MESSAGE 'Instanceインスタンス番号を指定してください' TYPE 'S' DISPLAY LIKE 'E'.
cv_error = 'X'.
EXIT.
* LEAVE LIST-PROCESSING.
ELSE.
ewoss-sr1inst = p_instno.
ENDIF.
ENDIF.
gv_val = 'X'.
ENDFORM. " VALIDATE
Thanks,
Naveen
2014 Dec 10 2:30 AM
Naveen,
Thank you for all the effort you have been putting. The latest source you gave me brings up the same issue I started the post for. Cursor always remains in the first field (Name) even if there is error in the IP address or Instance no.
Thanks.
2014 Dec 10 2:31 AM
2014 Dec 10 2:36 AM
Hi Gita,
for me it works perfectly. It gives error as required and the cursor is at the field for which the error is thrown.
Thanks,
Naveen
2014 Dec 10 2:48 AM
Hi Gita,
It works when you press an enter key rather than execute. It fails when you enter incorrect entry and click F8 or execute. For that I have done a work around as well. This should be the finl working one I guess. Please check below code and let me know if any issues:
TABLES: ewoss.
DATA: l_ev_rfc_options LIKE rfcdes-rfcoptions.
DATA:
d_gateway1ip LIKE rfcopt-rfchost ,
d_gateway1instanz LIKE rfcopt-rfcservice ,
d_gateway2ip LIKE rfcopt-rfchost ,
d_gateway2instanz LIKE rfcopt-rfcservice ,
d_sapservxip LIKE rfcopt-rfchost ,
d_sapservxinstanz LIKE rfcopt-rfcservice ,
d_oss_servname LIKE rfcopt-rfchost ,
d_oss_servinstanz LIKE rfcopt-rfcservice ,
gv_error TYPE char1.
SELECTION-SCREEN BEGIN OF BLOCK router WITH FRAME TITLE router.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(15) destin FOR FIELD p_dest.
PARAMETERS: p_dest TYPE ewoss-sr1name.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(15) ipadd FOR FIELD p_ipaddr.
PARAMETERS: p_ipaddr TYPE ewoss-sr1ip.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(15) instno FOR FIELD p_instno.
PARAMETERS: p_instno TYPE ewoss-sr1inst.
PARAMETERS : p_val TYPE char1 NO-DISPLAY.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK router.
INITIALIZATION.
router = 'SAPルータ'.
destin = '名称'.
ipadd = 'IP アドレス'.
instno = 'Instance no.'.
AT SELECTION-SCREEN OUTPUT.
CLEAR gv_error.
PERFORM validate CHANGING gv_error.
START-OF-SELECTION.
CLEAR gv_error.
PERFORM validate CHANGING gv_error.
IF gv_error IS INITIAL.
IF ewoss IS NOT INITIAL.
MODIFY ewoss.
IF sy-subrc <> 0.
WRITE: 'NG'.
ELSE.
d_gateway1ip = ewoss-sr1ip.
d_gateway1instanz = ewoss-sr1inst.
d_gateway2ip = ewoss-sr2ip .
d_gateway2instanz = ewoss-sr2inst.
d_sapservxip = ewoss-sapxip.
d_sapservxinstanz = ewoss-sapxinst.
d_oss_servname = ewoss-ossname.
d_oss_servinstanz = ewoss-ossinst.
* Function module to update the RFC destination
CALL FUNCTION 'EPS_UPDATE_RFC_DESTINATION'
EXPORTING
iv_router_1 = d_gateway1ip
iv_service_1 = d_gateway1instanz
iv_router_2 = d_gateway2ip
iv_service_2 = d_gateway2instanz
iv_router_sap = d_sapservxip
iv_service_sap = d_sapservxinstanz
iv_host_oss = d_oss_servname
iv_service_oss = d_oss_servinstanz
IMPORTING
ev_rfc_options = l_ev_rfc_options
EXCEPTIONS
router_path_too_long = 1
invalid_arguments = 2
update_failed = 3
OTHERS = 4.
IF sy-subrc <> 0.
WRITE: 'NG'.
ELSE.
WRITE: 'OK'.
ENDIF.
ENDIF.
ELSE.
WRITE: 'NG'.
ENDIF.
ENDIF.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Form VALIDATE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM validate CHANGING cv_error TYPE char1 .
SELECT SINGLE * FROM ewoss WHERE dummykey = space.
IF sy-subrc = 0 AND p_val = 'X'.
IF p_dest = space.
SET CURSOR FIELD 'P_DEST'.
MESSAGE 'destサーバ名を指定してください' TYPE 'S' DISPLAY LIKE 'E'.
cv_error = 'X'.
EXIT.
ELSE.
ewoss-sr1name = p_dest.
ENDIF.
IF ( p_ipaddr CN '0123456789. ' ) OR ( p_ipaddr = space ).
SET CURSOR FIELD 'P_IPADDR'.
MESSAGE 'IPアドレスを指定してください' TYPE 'S' DISPLAY LIKE 'E'.
cv_error = 'X'.
EXIT.
ELSE.
ewoss-sr1ip = p_ipaddr.
ENDIF.
IF ( p_instno CN '0123456789 ' ).
SET CURSOR FIELD 'P_INSTNO'.
MESSAGE 'Instanceインスタンス番号を指定してください' TYPE 'S' DISPLAY LIKE 'E'.
cv_error = 'X'.
EXIT.
ELSE.
ewoss-sr1inst = p_instno.
ENDIF.
ENDIF.
p_val = 'X'.
ENDFORM. " VALIDATE
Thanks,
Naveen
2014 Dec 10 2:48 AM
Oh really. Can u please share with me what inputs you gave to each field for every error?
Thanks
2014 Dec 10 2:52 AM
Excellent!!! It works, Thanks a lot Naveen for supporting me throughout this issue.
Full points!!!
BR,
Gita