Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 7790

How to do validation in Dynamic table update program?

$
0
0

Hi Experts,

 

I have a requirement to update any table by giving the table name, and an input file with table primary key and the field value need to update.

 

I am updating the table using the below code. Here I am getting the Primary keys and fields of the table using FM CACS_GET_TABLE_FIELDS.

 

But how can I check the full primary key of the table is available in the input file and corresponding entry is present in the table?

 

*--- Selection Screen
PARAMETERS: p_table
TYPE dd02l-tabname OBLIGATORY.
PARAMETERS: p_file
LIKE rlgrap-filename OBLIGATORY MEMORY ID ysm.


*--- Declarations for dynamic data
DATA gt_data TYPE REF TO data.
DATA GS_DATA TYPE REF TO data.

FIELD-SYMBOLS: <ft_data>
TYPE STANDARD TABLE,
<FS_DATA>
TYPE ANY.

START-OF-SELECTION.
*--- Create dynamic internal table
CREATE DATA gt_data TYPE TABLE OF (p_table).
ASSIGN gt_data->* TO <ft_data>.
*--- Create dynamic work area
CREATE DATA gs_data TYPE (p_table).
ASSIGN gs_data->* TO <fs_data>.
*--- Get Excel data in internal table
PERFORM f_convert_excel.
*--- Upload data to database table
PERFORM f_upload_table.
END-OF-SELECTION.


*&---------------------------------------------------------------------*
*& Form F_CONVERT_EXCEL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_convert_excel .


DATA lt_raw_data TYPE truxs_t_text_data.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
i_line_header =
'X'
i_tab_raw_data = lt_raw_data
i_filename = P_file
TABLES
i_tab_converted_data = <FT_DATA>
EXCEPTIONS
conversion_failed =
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.
ENDFORM.
" F_CONVERT_EXCEL


*&---------------------------------------------------------------------*
*& Form upload_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM f_upload_table.
SET UPDATE TASK LOCAL. " Switch to local update
LOOP AT <ft_data> ASSIGNING <fs_data>.
MODIFY (P_TABLE) FROM <FS_DATA>.
IF SY-SUBRC = 0.
GV_SUCCESS = GV_SUCCESS +
1.
ELSE.
delete <ft_data> index sy-tabix.
GV_ERROR = GV_ERROR +
1.
ENDIF.
ENDLOOP.
ENDFORM.
"upload_data

 

 

Regards,

Dipin


Viewing all articles
Browse latest Browse all 7790

Trending Articles



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