ENDFORM. "upload_dbf_file
*&---------------------------------------------------------------------*
*& Form read_dbf
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM read_dbf
TABLES pt_xdata
pt_dbf.
* Dbf Header
DATA: BEGIN OF ls_dbf_head
, date LIKE sy-datum
, rows TYPE int4
, start_offset TYPE int2
, row_len TYPE int2
, END OF ls_dbf_head.
* Fields Catalog
DATA: BEGIN OF lt_dbf_fields OCCURS 0
, name TYPE char10
, type TYPE c
, pos TYPE int4
, len TYPE int1
, digits TYPE int1
, END OF lt_dbf_fields.
DATA l_xdbf TYPE xstring.
DATA l_xstring TYPE xstring.
DATA l_xfield TYPE xstring.
DATA l_xrow TYPE xstring.
DATA l_len TYPE i.
DATA l_fields_len TYPE i.
DATA l_offset TYPE i.
DATA l_field_offset TYPE i.
FIELD-SYMBOLS <fs_x> TYPE ANY.
FIELD-SYMBOLS <fs_any> TYPE ANY.
FIELD-SYMBOLS <fs_value> TYPE ANY.
* All Table into X string
CLEAR l_xdbf.
LOOP AT pt_xdata ASSIGNING <fs_any>.
ASSIGN COMPONENT 1 OF STRUCTURE <fs_any> TO <fs_x>.
CHECK sy-subrc EQ 0.
l_xstring = <fs_x>.
CONCATENATE l_xdbf l_xstring INTO l_xdbf IN BYTE MODE.
ENDLOOP.
* Fill Dbf Header
CLEAR ls_dbf_head.
* Count of Rows
l_xstring = l_xdbf+4(4).
PERFORM convert_from_x
USING l_xstring
CHANGING ls_dbf_head-rows.
* Read Value
PERFORM convert_from_x
USING l_xstring
CHANGING <fs_value>.
ADD l_len TO l_field_offset.
ENDLOOP.
ADD l_field_offset TO l_offset.
APPEND pt_dbf.
ENDDO.
ENDFORM. " read_dbf
*&---------------------------------------------------------------------*
*& Form convert_from_x
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_L_XDBF+4(4) text
* <--P_LS_DBF_HEAD_ROWS text
*----------------------------------------------------------------------*
FORM convert_from_x USING p_xstring TYPE xstring
CHANGING p_value.
DATA l_type TYPE c.
DATA l_x00 TYPE x VALUE '00'.
DATA l_x20 TYPE x VALUE '20'.
* Convert From XString
DATA lc_conv TYPE REF TO cl_abap_conv_in_ce.
DATA l_len TYPE i.
DATA l_xstring TYPE xstring.
l_xstring = p_xstring.
DESCRIBE FIELD p_value TYPE l_type.
IF l_type CA 'Cg'.
REPLACE ALL OCCURRENCES OF l_x00 IN l_xstring WITH l_x20 IN BYTE MODE.
ENDIF.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.