Quantcast
Channel: SCN : All Content - ABAP Development
Viewing all articles
Browse latest Browse all 8332

Update dynpro field value after coroutine is done

$
0
0

Hi all

I have very simple dynpro based program with a bit challenge on background. The program consist of a text field as show on image:

Capture.PNG

Very simple application as I mentioned earlier :-) and the program looks like:

 

report zam_async_dialog.

data txt_input type c length 16.
data lf_msg type c length 80.
data ok_code type syucomm.
data lf_wait type i value 0.
data lf_worker_wait type i value 0.
data ls_dynpread type dynpread.
data lt_dynpread type standard table of dynpread.

start-of-selection.

   txt_input = 'WAIT'.

   call function 'ZAM_FUNCS_PARA_COUNTER'
     starting new task 'COROUTINE'
     destination in group default
     performing end_processing on end of task
     exceptions
       system_failure        = 1 message lf_msg
       communication_failure = 2 message lf_msg
       resource_failure      = 3.

   if sy-subrc <> 0.
     return.
   else.
     add 1 to lf_wait.
   endif.


   call screen '0100'.

*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module status_0100 output.
   set pf-status 'STATUS_100'.
   set titlebar 'TIT_100'.

endmodule.                 " STATUS_0100  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module user_command_0100 input.

   data lf_okcode type syucomm.
   call method cl_gui_cfw=>dispatch.
   lf_okcode = ok_code.
   case lf_okcode.
     when 'BACK'.
       set screen 0.
       leave screen.
   endcase.
endmodule.                 " USER_COMMAND_0100  INPUT



form end_processing using result.

   receive results from function 'ZAM_FUNCS_PARA_COUNTER'
     changing
       cf_finish = txt_input
     exceptions
       communication_failure = 1
       system_failure = 2.

   if sy-subrc = 0.
     move 'TXT_INPUT' to ls_dynpread-fieldname.
     move txt_input to ls_dynpread-fieldvalue.
     append ls_dynpread to lt_dynpread.

     call function 'DYNP_VALUES_UPDATE'
       exporting
         dyname               = sy-repid
         dynumb               = '0100'
       tables
         dynpfields           = lt_dynpread
       exceptions
         invalid_abapworkarea = 1
         invalid_dynprofield  = 2
         invalid_dynproname   = 3
         invalid_dynpronummer = 4
         invalid_request      = 5
         no_fielddescription  = 6
         undefind_error       = 7
         others               = 8.
   endif.

endform.


As you can see on the code, on the beginning of the application I called a function in a new task:

call function 'ZAM_FUNCS_PARA_COUNTER'
     starting new task 'COROUTINE'
     destination in group default
     performing end_processing on end of task
     exceptions
       system_failure        = 1 message lf_msg
       communication_failure = 2 message lf_msg
       resource_failure      = 3.


After the call is done, I will receive value from asyn call in the form


form end_processing using result.

   receive results from function 'ZAM_FUNCS_PARA_COUNTER'
     changing
       cf_finish = txt_input
     exceptions
       communication_failure = 1
       system_failure = 2.
 
endform.


Now my question is, how to tell the dynpro to show the new assigned value? I try with the function module:


move 'TXT_INPUT' to ls_dynpread-fieldname.
     move txt_input to ls_dynpread-fieldvalue.
     append ls_dynpread to lt_dynpread.

     call function 'DYNP_VALUES_UPDATE'
       exporting
         dyname               = sy-repid
         dynumb               = '0100'
       tables
         dynpfields           = lt_dynpread
       exceptions
         invalid_abapworkarea = 1
         invalid_dynprofield  = 2
         invalid_dynproname   = 3
         invalid_dynpronummer = 4
         invalid_request      = 5
         no_fielddescription  = 6
         undefind_error       = 7
         others               = 8.
  


But it does not work. My program structure looks:


Capture.PNG

Thanks for help

anujit marty


Viewing all articles
Browse latest Browse all 8332

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>