‎2007 Mar 07 2:15 PM
Hi all,
My code like this when i try to upload .txt .
txt file will be poplulating in Wa but not moving into itab.
OPEN DATASET P_FILE FOR INPUT IN TEXT MODE ENCODING UTF-8.
IF SY-SUBRC = 0.
DO.
READ DATASET P_FILE INTO WA_ITAB.
IF SY-SUBRC = 0.
SPLIT WA_ITAB AT '#' INTO ITAB-WERKS
ITAB-MATNR
ITAB-EKGRP
ITAB-LIFNR
ITAB-EVERS
L_MENGE.
ITAB-MENGE = L_MENGE.
APPEND ITAB.
CLEAR ITAB.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
CLOSE DATASET P_FILE.
‎2007 Mar 07 2:30 PM
Hi Devender,
May be '#' represents Horizontal tab, so do as follows.
OPEN DATASET P_FILE FOR INPUT IN TEXT MODE ENCODING UTF-8.
IF SY-SUBRC = 0.
DO.
READ DATASET P_FILE INTO WA_ITAB.
IF SY-SUBRC = 0.
SPLIT WA_ITAB AT <b>CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB</b> INTO ITAB-WERKS
ITAB-MATNR
ITAB-EKGRP
ITAB-LIFNR
ITAB-EVERS
L_MENGE.
ITAB-MENGE = L_MENGE.
APPEND ITAB.
CLEAR ITAB.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
CLOSE DATASET P_FILE.
Thanks,
Vinay
‎2007 Mar 07 2:18 PM
Hello,
Change the code like this:
OPEN DATASET P_FILE FOR OUTPUT " CHECK HERE
IN TEXT MODE ENCODING UTF-8.
IF SY-SUBRC = 0.
DO.
READ DATASET P_FILE INTO WA_ITAB.
IF SY-SUBRC = 0.
SPLIT WA_ITAB AT '#' INTO ITAB-WERKS
ITAB-MATNR
ITAB-EKGRP
ITAB-LIFNR
ITAB-EVERS
L_MENGE.
ITAB-MENGE = L_MENGE.
APPEND ITAB.
CLEAR ITAB.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
CLOSE DATASET P_FILE.
Vasanth
‎2007 Mar 07 2:18 PM
I presume you have debugged it and nothing is being passed into itab from the split statement.
‎2007 Mar 07 2:25 PM
‎2007 Mar 07 2:29 PM
Hello,
I think the '#' symbol u r seeing here is not actually hash.
Please check the delimiter of the file. The split command can't able to identiy the '#'symbel.
Vasanth
‎2007 Mar 07 2:29 PM
use cl_abap_char_utilities=>HORIZONTAL_TAB instead of # in split
split wa at cl_abap_char_utilities=>HORIZONTAL_TAB into....
‎2007 Mar 07 2:30 PM
Hi Devender,
May be '#' represents Horizontal tab, so do as follows.
OPEN DATASET P_FILE FOR INPUT IN TEXT MODE ENCODING UTF-8.
IF SY-SUBRC = 0.
DO.
READ DATASET P_FILE INTO WA_ITAB.
IF SY-SUBRC = 0.
SPLIT WA_ITAB AT <b>CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB</b> INTO ITAB-WERKS
ITAB-MATNR
ITAB-EKGRP
ITAB-LIFNR
ITAB-EVERS
L_MENGE.
ITAB-MENGE = L_MENGE.
APPEND ITAB.
CLEAR ITAB.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
CLOSE DATASET P_FILE.
Thanks,
Vinay
‎2007 Mar 07 2:34 PM
‎2007 Mar 07 2:46 PM
Hi Devender,
remeber ther is no splitting # .For a tab delimited file you see # symbol.
If you want to split
use the following syntax
for >= 4.6 c version
constants: con_tab type x value '09'
split xyz_file at con_tab into ---
for versions <= 4.7
constants: con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB.
split xyz_file at con_tab into ---
hope you are clear.
Thanks
venki
‎2007 Mar 07 4:59 PM
Hi Devender,
Thanks for your words and You can find my email address on business card.
Thanks,
Vinay
‎2007 Mar 07 2:32 PM
Hi,
split the value into work area and then append it into internal table:
SPLIT WA_ITAB AT '#' INTO <b>WA_ITAB-WERKS</b>
-
-
<b>append WA_ITAB to ITAB.</b>
Regards,
Chanadn