on 03-06-2013 9:10 AM
HI,
I have a action that selects data from a parameter and it is all fine. But, I have had to make some more validations on the data
before outputting it in my View.
How can I after validation write my data to my existing context node; (I want to avoid creating additional nodes) ?
Code below:
METHOD onactiongetdata .
TYPES:
lty_r_pspnr TYPE RANGE OF ps_posnr,
tty_empwbs TYPE STANDARD TABLE OF zhr_empwbs.
TYPES: BEGIN OF ty_output,
pernr TYPE persno,
pspnr TYPE ps_posnr,
posid TYPE ps_posid,
sdatum TYPE begda,
edatum TYPE endda,
crdat TYPE crdat,
crnam TYPE crnam,
aedat TYPE aedat,
aenam TYPE aenam,
ename TYPE emnam,
post1 TYPE ps_post1,
END OF ty_output.
* Declarations for filtering
DATA: gt_output TYPE TABLE OF ty_output,
gs_output TYPE ty_output.
* Declarations for check for active project
DATA: gt_final TYPE TABLE OF ty_output,
gs_final TYPE ty_output.
DATA: lv_tabix TYPE sytabix,
lt_ee_tab TYPE pernr_us_tab,
ls_ee_tab LIKE LINE OF lt_ee_tab,
lv_perno TYPE persno,
ls_prps TYPE prps.
* Itabs
DATA:
lr_empwbs TYPE REF TO if_wd_context_node,
lt_empwbs TYPE STANDARD TABLE OF zhr_empwbs.
* lt_empwbs_s1 TYPE STANDARD TABLE OF zhr_empwbs, "Data after filtering for responsible
* lt_empwbs_s2 TYPE STANDARD TABLE OF zhr_empwbs. "Data after filtering for active project
* Work areas
DATA: wa_jest TYPE jest.
* Final binding def.
DATA: it_empwbs TYPE STANDARD TABLE OF if_main=>element_empwbs.
* Variables used to retrieve the values of select-options fields
DATA: lt_sel_item TYPE if_wd_select_options=>tt_selection_screen_item.
FIELD-SYMBOLS:
<fs_sel_item> LIKE LINE OF lt_sel_item,
<fs_pspnr> TYPE any.
* Get the selection-screen items
wd_this->m_helper->get_selection_screen_items(
IMPORTING et_selection_screen_items = lt_sel_item ).
* Retrieve the values from the select-options items
LOOP AT lt_sel_item ASSIGNING <fs_sel_item>.
CASE <fs_sel_item>-m_id.
WHEN `PSPNR`. "WBS Number
ASSIGN <fs_sel_item>-m_value->* TO <fs_pspnr>.
ENDCASE.
ENDLOOP.
* Retrieve the data from the database table
SELECT * "pernr pspnr sdatum edatum
FROM zhr_empwbs
INTO CORRESPONDING FIELDS OF TABLE gt_output "wd_this->empwbs
* INTO CORRESPONDING FIELDS OF TABLE lt_empwbs
WHERE pspnr = <fs_pspnr>.
* Filter the data for responsible
LOOP AT gt_output INTO gs_output.
lv_tabix = sy-tabix.
* Delete entries where actual user is not responsible
CALL FUNCTION 'HR_GET_EMPLOYEES_FROM_USER'
EXPORTING
user = sy-uname
begda = sy-datum
endda = sy-datum
iv_with_authority = 'X'
TABLES
ee_tab = lt_ee_tab.
CHECK lt_ee_tab[] IS NOT INITIAL.
READ TABLE lt_ee_tab INTO ls_ee_tab INDEX 1.
SELECT SINGLE * INTO ls_prps
FROM prps
WHERE pspnr = gs_output-pspnr
AND zzaun = ls_ee_tab-pernr.
IF sy-subrc <> 0.
DELETE gt_output INDEX lv_tabix.
CONTINUE.
ENDIF.
CALL FUNCTION 'CONVERSION_EXIT_ABPSP_OUTPUT'
EXPORTING
input = gs_output-pspnr
IMPORTING
output = gs_output-posid.
MODIFY gt_output FROM gs_output INDEX lv_tabix. "Filtered result is in GT_OUTPUT now.
ENDLOOP.
** Check that project is active
LOOP AT gt_output INTO gs_final. "INTO gs_final.
SELECT SINGLE *
FROM jest
INTO wa_jest
WHERE objnr = gs_final-pspnr
AND stat = 'i0002'
AND inact = ' '.
IF sy-subrc = 0. "If project is active then write to final result
* Here I want to write my data to the node below (wd_this->empwbs)
ENDIF.
ENDLOOP.
* Bind the data to the context
lr_empwbs = wd_context->get_child_node( name = `EMPWBS` ).
lr_empwbs->bind_table( wd_this->empwbs ).
ENDMETHOD.
Hi Peter,
You can do validations in WDDOBEFOREACTION Method or in the same method where you are processing the data.
In the same method ( ONACTIONGETDATA)
if you want to populate data to a Table UI,
get the data in to internal table ( lt_tab ).
*Now process the data or do validations
loop at lt_tab into ls_tab.
* Check the conditions and add the valid data to final itab.
append ls_tab to lt_final_tab.
endloop.
Now the require data will be in lt_final_tab. Bind this to the node using bind_table method
lo_nd_table->bind_table( lt_final_tab ).
Regards,
Kiran
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi peter,
read the node to a local table/structure and once your validation is done,
Invalidate the node & bind the data to node.
Thanks
Manish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.