0% found this document useful (0 votes)
28 views3 pages

RESV

The document outlines an ABAP report named ZRESB_UPDATE that facilitates the upload of a CSV file and updates the RESB table in the SAP system. It includes functionality for file selection, data reading, and processing, ensuring that data is correctly formatted and converted before being inserted into the RESB table. Error handling is also implemented to manage potential issues during the file upload process.

Uploaded by

pandu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views3 pages

RESV

The document outlines an ABAP report named ZRESB_UPDATE that facilitates the upload of a CSV file and updates the RESB table in the SAP system. It includes functionality for file selection, data reading, and processing, ensuring that data is correctly formatted and converted before being inserted into the RESB table. Error handling is also implemented to manage potential issues during the file upload process.

Uploaded by

pandu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

*&---------------------------------------------------------------------*

*& Report ZRESB_UPDATE


*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT zresb_update.

TABLES: rlgrap.
PARAMETERS: p_file TYPE rlgrap-filename.
***********************************************************************
* At Selection-screen of value request
***********************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CALL FUNCTION 'F4_FILENAME'


EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = ' '
IMPORTING
file_name = p_file.

START-OF-SELECTION.

*-- Updated
DATA l_files TYPE string.

DATA : lt_resb TYPE STANDARD TABLE OF resb,


ls_resb TYPE resb.

DATA: BEGIN OF itab OCCURS 0,


xline(2000) TYPE c,
END OF itab.
DATA : wa_itab TYPE string.
DATA: gv_table_name TYPE string,
gr_type_desc TYPE REF TO cl_abap_typedescr,
gr_struct_desc TYPE REF TO cl_abap_structdescr,
gr_table_desc TYPE REF TO cl_abap_tabledescr,
gv_t TYPE c,
gv_comp TYPE i,
gr_table_ref TYPE REF TO data,
gr_struc_ref TYPE REF TO data.

DATA: gt_itab TYPE TABLE OF string,


gt_split TYPE TABLE OF string,
gv_str TYPE string.

FIELD-SYMBOLS: <table> TYPE ANY TABLE,


<struct> TYPE any,
<comp> TYPE any.
l_files = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_files
filetype = 'ASC'
* HAS_FIELD_SEPARATOR = ' '
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* VIRUS_SCAN_PROFILE =
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = itab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17 .
IF sy-subrc <> 0.
WRITE: / 'Upload .CSV File Failed', sy-subrc.
EXIT.
ENDIF.

"go!
gv_table_name = 'RESB'.

cl_abap_tabledescr=>describe_by_name(
EXPORTING p_name = gv_table_name
RECEIVING p_descr_ref = gr_type_desc
EXCEPTIONS type_not_found = 4 ).

gr_struct_desc ?= gr_type_desc.
gr_table_desc = cl_abap_tabledescr=>create( gr_struct_desc ).
CREATE DATA gr_table_ref TYPE HANDLE gr_table_desc.
CREATE DATA gr_struc_ref TYPE HANDLE gr_struct_desc.
ASSIGN gr_table_ref->* TO <table>.
ASSIGN gr_struc_ref->* TO <struct>.
DESCRIBE FIELD <struct> TYPE gv_t COMPONENTS gv_comp.
DATA : lv_date TYPE sy-datum.
LOOP AT itab INTO gv_str.
CLEAR: gt_split.
SPLIT gv_str AT '|' INTO TABLE gt_split.
DO gv_comp TIMES.
READ TABLE gt_split INTO gv_str INDEX sy-index.
ASSIGN COMPONENT sy-index OF STRUCTURE <struct> TO <comp>.
CONDENSE gv_str.
FIND ',' IN gv_str.
IF sy-subrc EQ 0.
REPLACE ALL OCCURRENCES OF ',' IN gv_str WITH '.'.
<comp> = gv_str.
ELSE.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = gv_str
IMPORTING
date_internal = lv_date
EXCEPTIONS
date_external_is_invalid = 1
OTHERS = 2.
IF sy-subrc EQ 0.
<comp> = lv_date.
ELSE.
<comp> = gv_str.
ENDIF.
ENDIF.
CLEAR: gv_str.
ENDDO.
INSERT <struct> INTO TABLE <table>.
CLEAR : <comp>.
ENDLOOP.

IF <table> IS NOT INITIAL.


MODIFY resb FROM TABLE <table>.
ENDIF.

You might also like