2009 Apr 28 6:26 PM
Hello All!
I have a slightly frustrating problem. I have built a Module Pool application to display shipments and their underlying deliveries (various information from each).
I have structured the application as follows
An object to store the Data. This object has an internal table of Shipments and an internal table of Deliveries. The tables are related by TKNUM. When the application needs to display a shipment, it requests the shipment's information and the underlying deliveries information from the object. The object is structured to move through the shipments with methods like "GetFirstHeader", "GetPrevHeader", "GetNextHeader", "GetLastHeader". These return the data for the application to use.
The Deliveries are displayed in a CL_SALV_TABLE, the Shipment information is displayed in textbox type fields above the table.
The form for display has buttons to trigger the "Move" methods of the data object. This currently will retrieve the new data from the object, modify the fields and the alv grid and then go back through PBO (I'm assuming because a button was pressed). This works well. It will bring in the new data and refresh the screen everything is fine.
I also have a button to print the currently displayed Shipment and Deliveries. This Print is handled through a SmartForm.
The area that is giving me troubles is my other button. Since the Application can store a range of shipments at once, I have a "Print All" button. This button moves to the first shipment in the data object,
calls the Print Form, then moves through the rest of the data object calling the Print Form for each Shipment Displayed. This happens from one button push. The problem I am running into is that the screen does not refresh when the data changes during this movement through the data objects. I believe this is due to the PBO module not being triggered yet. My question is, is there a way to refresh the screen progmatically?
I have tried SET USER-COMMAND to move through the data, instead of calling the "GetFirstHeader" and "GetNextHeader" method directly, but that has some unpredictable behavior (works in debug, not in regular execution). I have also tried a LEAVE SCREEN statement, as that would trigger the PBO, since the Next Screen is set to the same screen number, but that kills execution of that block of code at the LEAVE SCREEN STATEMENT.
I am including my code from my PAI module that runs this processing, hopefully that will help.
<< unformatable code removed >>
Moderator message - Please go through your code and post only what is relevant to your question.
Edited by: Rob Burbank on Apr 28, 2009 1:44 PM
2009 Apr 28 11:29 PM
Hello Steven,
There is a Function you can use to Update a Screen Field without going through PBO.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
dyname = sy-repid
dynumb = sy-dynnr
TABLES
dynpfields = it_dynpread.You can check the structure of the table "dynpfields" it receives as a parameter, you just have to send the name of the fields and the values for them, hope it helps,
Luis.
2009 Apr 28 6:26 PM
Sorry about that, that was weird. I'll try reposting in readable format. Maybe if I split my message and the code.
2009 Apr 28 6:28 PM
Message:
Hello All! I have a slightly frustrating problem. I have built a Module Pool application to display shipments and their underlying deliveries (various information from each). I have structured the application as follows An object to store the Data. This object has an internal table of Shipments and an internal table of Deliveries. The tables are related by TKNUM. When the application needs to display a shipment, it requests the shipment's information and the underlying deliveries information from the object. The object is structured to move through the shipments with methods like "GetFirstHeader", "GetPrevHeader", "GetNextHeader", "GetLastHeader". These return the data for the application to use.
The Deliveries are displayed in a CL_SALV_TABLE, the Shipment information is displayed in textbox type fields above the table. The form for display has buttons to trigger the "Move" methods of the data object. This currently will retrieve the new data from the object, modify the fields and the alv grid and then go back through PBO (I'm assuming because a button was pressed). This works well. It will bring in the new data and refresh the screen everything is fine.
I also have a button to print the currently displayed Shipment and Deliveries. This Print is handled through a SmartForm.
The area that is giving me troubles is my other button. Since the Application can store a range of shipments at once, I have a "Print All" button. This button moves to the first shipment in the data object, calls the Print Form, then moves through the rest of the data object calling the Print Form for each Shipment Displayed. This happens from one button push. The problem I am running into is that the screen does not refresh when the data changes during this movement through the data objects. I believe this is due to the PBO module not being triggered yet. My question is, is there a way to refresh the screen progmatically?
I have tried SET USER-COMMAND to move through the data, instead of calling the "GetFirstHeader" and "GetNextHeader" method directly, but that has some unpredictable behavior (works in debug, not in regular execution). I have also tried a LEAVE SCREEN statement, as that would trigger the PBO, since the Next Screen is set to the same screen number, but that kills execution of that block of code at the LEAVE SCREEN STATEMENT. I am including my code from my PAI module that runs this processing, hopefully that will help.
2009 Apr 28 6:30 PM
<< Unformatable code removed >>
Edited by: Rob Burbank on Apr 28, 2009 1:46 PM
2009 Apr 28 6:31 PM
2009 Apr 28 7:35 PM
MODULE USER_COMMAND_9999 INPUT .
CASE OK_CODE .
WHEN 'NEXT' .
PERFORM Next .
PERFORM GetGridData .
PERFORM RefreshALV .
WHEN 'PREV' .
PERFORM Prev .
PERFORM GetGridData .
PERFORM RefreshALV .
WHEN 'EXIT' .
SET SCREEN 0 .
WHEN 'PRNT' .
PERFORM Print .
WHEN 'PRNA' .
PERFORM PrintAll .
WHEN 'BACK' .
PERFORM HideInitials .
SET SCREEN '1000' .
WHEN 'CANC' .
SET SCREEN '1000' .
WHEN 'FRST' .
PERFORM First .
PERFORM GetGridData .
PERFORM RefreshALV .
WHEN 'LAST' .
PERFORM Last .
PERFORM GetGridData .
PERFORM RefreshALV .
WHEN 'CFAX' .
PERFORM Show6000 .
ENDCASE .
ENDMODULE .
FORM PrintAll .
DATA sPromptB TYPE STRING .
DATA sPromptM TYPE STRING .
DATA sPromptE TYPE STRING .
DATA sPromptF TYPE STRING .
DATA cAnswer TYPE C LENGTH 1 .
IF NOT oLTend->isEmpty( ) = 1 .
sPromptB = text-995 .
sPromptM = ITOTSHIPNUM .
sPromptE = text-994 .
CONCATENATE sPromptB sPromptM sPromptE INTO sPromptF SEPARATED BY SPACE .
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = 'Print All?'
TEXT_QUESTION = sPromptF
DISPLAY_CANCEL_BUTTON = ' '
IMPORTING
ANSWER = cAnswer
EXCEPTIONS
TEXT_NOT_FOUND = 1
OTHERS = 2 .
IF SY-SUBRC <> 0 .
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4 .
ENDIF .
IF cAnswer = '1' .
PERFORM First .
PERFORM GetGridData .
PERFORM RefreshALV .
" >>> Need Screen Refreshed right here
PERFORM Print .
DO .
PERFORM Next .
PERFORM GetGridData .
PERFORM RefreshALV .
" >>> Need Screen Refreshed right here
PERFORM Print .
IF oLTend->GetIndex( ) = oLTend->GetCount( ) .
EXIT .
ENDIF .
ENDDO .
ENDIF .
ENDIF .
ENDFORM .
That is the general flow. Hope that helps, if more info is needed, let me know.
2009 Apr 28 11:29 PM
Hello Steven,
There is a Function you can use to Update a Screen Field without going through PBO.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
dyname = sy-repid
dynumb = sy-dynnr
TABLES
dynpfields = it_dynpread.You can check the structure of the table "dynpfields" it receives as a parameter, you just have to send the name of the fields and the values for them, hope it helps,
Luis.
2009 Apr 29 2:11 PM
This is exactly the kind of solution I was hoping for.
Thank you,
2015 Dec 28 9:42 AM
THe code to read and update the Module pool Screen fields is below:
In this below example we are reading Job field value and updating Job text field on Module pool screen.
DATA: BEGIN OF htab OCCURS 2.
INCLUDE STRUCTURE dynpread.
DATA: END OF htab.
DATA: lv_stell TYPE wplog-objid,
lv_stltx TYPE stltx.
CLEAR htab. REFRESH htab.
MOVE job_field_name TO htab-fieldname.
CLEAR htab-fieldvalue.
APPEND htab.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = sy-cprog
dynumb = sy-dynnr
TABLES
dynpfields = htab
EXCEPTIONS
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
invalid_parameter = 7
undefind_error = 8
OTHERS = 9.
IF sy-subrc EQ 0.
READ TABLE htab WITH KEY fieldname = job_field_name.
* Search Position text
CLEAR: lv_stltx, lv_stell.
MOVE htab-fieldvalue TO lv_stell.
SELECT SINGLE stltx FROM t513s INTO lv_stltx
WHERE sprsl EQ sy-langu
AND stell EQ lv_stell.
Job_text_field_name = lv_stltx.