2004 Nov 17 8:09 AM
Hi,
Currently using SAP 4.7 SAPKB62011
The need was to develop a program, which based on a selection-criteria displays a table(editable) and some changes will be done in the table and data should get saved.
The best approach I assumed was to
a) Create a report, define the selection screen parameters
b) Do validation in at selection-screen
c) If all validations are proper, select values to be shown in table control
d) call screen 9000
Everything is working perfectly, except for adding new lines in table control.
When I execute select query in AT SELECTION-SCREEN event before calling the screen 9000, then I am not able to add values to table control.
But if I put the select query in the PBO of screen 9000, I am able to add new values. Only those values which are already present in table control can be changed. I am not able to add any new entries.
In my opinion, there should not be a select query in PBO, because that query would hit the database in all possible events.
Any particular reason, why.
<b>AT SELECTION-SCREEN code</b>
AT SELECTION-SCREEN.
CASE sy-ucomm.
WHEN 'ONLI'.
lv_pernr = p_pernr.
lv_lifnr = p_lifnr.
* SELECT *
* FROM zpersoninfo
* INTO TABLE lt_zpersoninfo
* WHERE personno = lv_pernr.
*
* IF sy-subrc <> 0.
* ENDIF.
* APPEND INITIAL LINE TO LT_ZPERSONINFO.
CALL SCREEN 9000.
ENDCASE.
<b>Dynpro code</b>
PROCESS BEFORE OUTPUT.
MODULE pbo_9000.
LOOP AT lt_zpersoninfo INTO zpersoninfo WITH CONTROL tablecontrol CURSOR
tablecontrol-current_line.
MODULE pbo_tc_9000.
ENDLOOP.
PROCESS AFTER INPUT.
LOOP.
MODULE pai_tc_9000.
ENDLOOP.
MODULE pai_9000.
<b>PBO_9000</b>
MODULE pbo_9000 OUTPUT.
SET PF-STATUS lv_pfstatus.
pa0315-pernr = lv_pernr.
SELECT *
FROM zpersoninfo
INTO TABLE lt_zpersoninfo
WHERE personno = lv_pernr.
IF sy-subrc <> 0.
ENDIF.
APPEND INITIAL LINE TO LT_ZPERSONINFO.
ENDMODULE. " PBO_9000 OUTPUT
<b>PBO 9000 - Table Control Code</b>
MODULE pbo_tc_9000 OUTPUT.
LOOP AT SCREEN.
IF lv_pfstatus = 'DISPLAY'.
CASE screen-name.
WHEN 'ZPERSONINFO-SERVICENO'.
screen-input = '1'.
screen-active = '1'.
WHEN 'ZPERSONINFO-MANDATORY'.
screen-input = '1'.
screen-active = '1'.
ENDCASE.
ELSEIF lv_pfstatus = 'CHANGE'.
CASE screen-name.
WHEN 'ZPERSONINFO-SERVICENO'.
screen-input = '0'.
WHEN 'ZPERSONINFO-MANDATORY'.
screen-input = '0'.
ENDCASE.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
ENDMODULE.
Let me know if I have skipped some information, which you may find it useful to find the solution.
Regards,
Subramanian V.
2004 Nov 17 8:31 AM
That is because I didn't upate the 'LINES' field in tablecontrol. How silly !!
Regards,
Subramanian V.