cancel
Showing results for 
Search instead for 
Did you mean: 

How to stop execution of next methods in WDA

sivab4u
Active Participant
0 Kudos

Hi Experts,

I am working on WDA Application, i have a scenario to upload files of PDF Format only, so when user clicks on attachment button on main View. it pops up a external window(Another view using external window method) with file upload ui element, now end user have uploads the file and click on upload button. so on click of upload button it closes the current window and throws a message upload PDF in main view, if the file is not PDF(I am validating in wdmodifyview for check the file is pdf or not).

but my requirement is if the file is not pdf file i have to throw an error when user click on upload button. and it should stay on same pop up window instead of going to Main View.

     structure of WDA Components:

          main_window which has ---> main_view   on click of button attachment it will call

          attach_window which has --> attach_view.

now if the file is not pdf it should stop from closing the pop up window on click of upload/OK Button, how to achieve this

Accepted Solutions (1)

Accepted Solutions (1)

nishantbansal91
Active Contributor
0 Kudos

Dear Siva b,

Instead of writing the code in the modfiy view method, can you please write the same code into Before action method of the Attach View.

Thanks and Regards,

Nishant

sivab4u
Active Participant
0 Kudos

Hi Nishant,

Thanks for ur prompt reply, if i write my code in do before action the error is getting triggered but the message is displayed in main view after closing the pop up window, i need to stop it from closing and error to show above note in pop up screen itself how to achieve this, for better understanding see image below:

ramakrishnappa
Active Contributor
0 Kudos

Hi Siva,

You need to write the validation logic inside the wddobeforeaction of ATTACH_VIEW . ( not in main view ).

Please check the below document in which I have explained about the validation on popup window.

Hope this helps you.

Regards,

Rama

sivab4u
Active Participant
0 Kudos

Thanks Rama krishna,

from ur post i am able to trigger the do before action for ok button, but now the issue is in wdmodify view of attach_view i am using below code:

DATA O_UPLOAD TYPE REF TO CL_WD_FILE_UPLOAD.

DATA LV_STRING TYPE STRING.

DATA LV_STR_LEN TYPE I.

DATA LV_FORMAT(3).

  O_UPLOAD ?= VIEW->GET_ELEMENT( 'FU' ).

CLEAR: LV_STRING, LV_STR_LEN, LV_FORMAT.

    LV_STRING = O_UPLOAD->GET_FILE_NAME( ).

    LV_STR_LEN = STRLEN( LV_STRING ) - 3.

    IF LV_STR_LEN GT 0.

      LV_FORMAT = LV_STRING+LV_STR_LEN(3).

      TRANSLATE LV_FORMAT TO UPPER CASE.

    ENDIF.

IF LV_FORMAT EQ 'PDF'.

    ELSE.

*       get message manager

      LO_API_CONTROLLER ?= WD_THIS->WD_GET_API( ).

      CALL METHOD LO_API_CONTROLLER->GET_MESSAGE_MANAGER

        RECEIVING

          MESSAGE_MANAGER = LO_MESSAGE_MANAGER.

*       report message

      CALL METHOD LO_MESSAGE_MANAGER->REPORT_ERROR_MESSAGE

        EXPORTING

          MESSAGE_TEXT = 'Upload file of ''PDF'' Format only'.

    ENDIF.

so how do i capture the file format in wddobefore action to throw error if not PDF Format.

Regards,

Siva

former_member184578
Active Contributor
0 Kudos

Hi,

You could use the get_attribute( ) method of context and get the file name and file format in the DOBEFOREACTION method itself.

Regards,

Kiran

Answers (1)

Answers (1)

Former Member
0 Kudos

hi Siva,

If you are using your file upload view as a popup then, While calling this window make close_in_any_case as false and write your validation code in wddoinit of popup view.

      LO_WINDOW = LO_WINDOW_MANAGER->CREATE_WINDOW(

          WINDOW_NAME                 = 'W_POP_UP'

          TITLE                                  = 'Comment'

          CLOSE_IN_ANY_CASE         = ABAP_FALSE

          MESSAGE_DISPLAY_MODE = IF_WD_WINDOW=>CO_MSG_DISPLAY_MODE_SELECTED

          CLOSE_BUTTON                   = ABAP_TRUE

          BUTTON_KIND                     = IF_WD_WINDOW=>CO_BUTTONS_OK

          MESSAGE_TYPE                = IF_WD_WINDOW=>CO_MSG_TYPE_NONE

          DEFAULT_BUTTON                = IF_WD_WINDOW=>CO_BUTTON_IGNORE

Cheers

Amod