2018 Oct 07 6:03 AM
Hi All,
I am new to ABAP and currently working on an ABAP program that will read data from a comma separated text file and upload to a custom table that i created.
After referring to loads of videos in youtube and in Sap community sites, i manged to do half of my requirement.
The below code reads the csv file using GUI_UPLOAD function into an Internal table called UTAB. UTAB contains data of format 1 - Name,Address, Contact
An other Internal table called DTAB is defined that will read the data from UTAB and splits the value using comma (,) and stores the data like this.
1.Name
2.Address
3.Contact
Now i need to somehow loop through these values in DTAB and store them in my custom table ZCUST_DETAIL.
Please help me complete the code.
REPORT ZZ_UPLOAD_GEACACCOUNT.
PARAMETERS: P_FNAME TYPE STRING OBLIGATORY
DATA UTAB TYPE TABLE OF CHAR300.
FIELD-SYMBOLS <FS_UTAB> LIKE LINE OF UTAB.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
EXPORTING
FILENAME = P_FNAME
CHANGING
DATA_TAB = UTAB
EXCEPTIONS
FILE_OPEN_ERROR = 1.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
* EXCEL DATA IS NOW IN UTAB TABLE
DATA DTAB TYPE TABLE OF CHAR100.
FIELD-SYMBOLS <FS_DTAB> LIKE LINE OF DTAB.
LOOP AT UTAB ASSIGNING <FS_UTAB> FROM 2.
SPLIT <FS_UTAB> AT ',' INTO TABLE DTAB
ENDLOOP.
2018 Oct 08 9:41 AM
Dear M Jay,
Instead of this:
SPLIT <FS_UTAB> AT ',' INTO TABLE DTABPlease try this:
DATA: Dtab TYPE STANDARD TABLE OF ZCUST_DETAIL,
wa_dtab TYPE ZCUST_DETAIL.
"(you can also define internal table structure manually instead of using standard table)
............
............
............
SPLIT <FS_UTAB> AT ',' INTO wa_dtab-name wa_dtab-address wa_dtab-contact.
Append wa_dtab INTO dtab.
Please let me know if you need further clarifications on this.
Thanks and Regards,
Arpan Shukla
Dear M Jay,
Instead of this:
SPLIT <FS_UTAB> AT ',' INTO TABLE DTABPlease try this:
DATA: Dtab TYPE STANDARD TABLE OF ZCUST_DETAIL,
wa_dtab TYPE ZCUST_DETAIL.
"(you can also define internal table structure manually instead of using standard table)
............
............
............
SPLIT <FS_UTAB> AT ',' INTO wa_dtab-name wa_dtab-address wa_dtab-contact.
Append wa_dtab INTO dtab.
Please let me know if you need further clarifications on this.
Thanks and Regards,
Arpan Shukla
2018 Oct 07 8:09 AM
Please in future use the code button when entering code. I've done it for you this time.
Matt Billigham - SAP Community Moderator
2018 Oct 08 9:41 AM
Dear M Jay,
Instead of this:
SPLIT <FS_UTAB> AT ',' INTO TABLE DTABPlease try this:
DATA: Dtab TYPE STANDARD TABLE OF ZCUST_DETAIL,
wa_dtab TYPE ZCUST_DETAIL.
"(you can also define internal table structure manually instead of using standard table)
............
............
............
SPLIT <FS_UTAB> AT ',' INTO wa_dtab-name wa_dtab-address wa_dtab-contact.
Append wa_dtab INTO dtab.
Please let me know if you need further clarifications on this.
Thanks and Regards,
Arpan Shukla
2018 Oct 08 3:56 PM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |