I have an application server file.
I need to read the file and keep the data into internal table.
I have the below data in application server file.
2009010000000112300012030850000114792110~ 43958.780.000USD ~
2009010000000112100012241060000114792110~ 136402.290.000USD ~
2009010000004077000040010240000114792110~ -132632.930.000USD ~
2009010000000112000012010100000114792110~ 715218.250.000USD ~
I have declared my internal table as....
*-Type for input file internal table.
TYPES : BEGIN OF tp_input_trans_file_data,
posting_period TYPE char07, " Posting period
grp_account TYPE char10, " Group Account Number
account TYPE char10, " G/L account number
cost_center TYPE char10, " Cost Center
currency_type TYPE char3, " 3-Byte field
document_type TYPE char_02, " Document type
amount_balance TYPE p DECIMALS 2," 17 2 Total of transactions of the period in group currency
quantity_balance TYPE p DECIMALS 3," MENGE_D, " Total of the transactions of period in units of measure
currency_code TYPE waers_curc, " Currency Key
unit_of_meas TYPE lagme, " Base Unit of Measure
END OF tp_input_trans_file_data.
Reading input file in below routine...
Form read_input_file.
DATA : wa_ip_fline TYPE string.
DATA : h_offset TYPE i VALUE '0',
lv_amt_bal TYPE char17,
lv_qty_bal TYPE char17.
The file mentioned in the server file path is created.
OPEN DATASET p_ifname FOR INPUT IN TEXT MODE ENCODING DEFAULT.
DO.
CLEAR : wa_ip_fline, h_offset.
READ DATASET p_ifname INTO wa_ip_fline.
IF sy-subrc NE 0.
EXIT.
ELSE.
*put corresponsing values of file into workarea
SPLIT wa_ip_fline AT '~'
INTO wa_trans_file_data-posting_period
wa_trans_file_data-grp_account
wa_trans_file_data-account
wa_trans_file_data-cost_center
wa_trans_file_data-currency_type
wa_trans_file_data-document_type
lv_amt_bal
lv_qty_bal
wa_trans_file_data-currency_code
wa_trans_file_data-unit_of_meas.
wa_trans_file_data-amount_balance = lv_amt_bal .
wa_trans_file_data-quantity_balance = lv_qty_bal.
APPEND wa_trans_file_data TO p_itab_trans_file_data.
CLEAR : wa_trans_file_data.
ENDIF.
ENDDO.
CLOSE DATASET p_ifname.
Please validate above idea is correct or not ?
However, say for even first record
2009010000000112300012030850000114792110~ 43958.780.000USD ~
'~' value is sitting in last field which is not correct and hwo to avoid this ?
POSTING_PERIOD = 2009010
GRP_ACCOUNT = 0000001120
ACCOUNT = 0001201010
COST_CENTER = 0000114792
CURRENCY_TYPE = 110
DOCUMENT_TYPE =
AMOUNT_BALANCE = 715218.25
QUANTITY_BALANCE = 0.000
CURRENCY_CODE = USD
UNIT_OF_MEAS = ~
YOUR HELP IS HIGHLY APPRECIATED. THANKS IN ADVANCE.