Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Can't input workarea value into table.

Former Member
0 Likes
896

It's Unicode not convertible error. If i change ty_pa0002, it wont be able to catch the value from the excel file which converted to CSV.

How can i solve this problem?


TYPES: BEGIN of ty_pa0002,
       DF TYPE CHAR9,
       BBTNO TYPE CHAR4,
       VOL TYPE CHAR11,
       DP TYPE CHAR11,
       AVP TYPE CHAR6,
       VARIANCE TYPE CHAR6,
       RBBT TYPE CHAR6,
       RV TYPE CHAR6,
       STATUS TYPE CHAR31,
END of ty_pa0002.

data: it_final type standard table of ty_pa0002 with header line.
DATA: IT_PA0002 TYPE TABLE OF TY_PA0002 WITH HEADER LINE.
data: it_temp type standard table of ty_pa0002 with header line.
DATA: WA_TEMP TYPE TY_PA0002.
DATA: TEMSTR TYPE CHAR300.

OPEN DATASET FILE_PATH FOR INPUT IN TEXT MODE ENCODING DEFAULT.
DO.
   READ DATASET FILE_PATH INTO TEMSTR.
   IF SY-SUBRC = 0.
     SPLIT TEMSTR AT ',' INTO WA_TEMP-DF WA_TEMP-BBTNO WA_TEMP-VOL WA_TEMP-DP WA_TEMP-AVP WA_TEMP-VARIANCE WA_TEMP-RBBT WA_TEMP-RV WA_TEMP-STATUS.
     APPEND WA_TEMP TO IT_FINAL.
   ELSE.
     EXIT.
   ENDIF.
ENDDO.

CLEAR WA_TEMP.

LOOP AT IT_FINAL INTO WA_TEMP.
     IF SY-TABIX = 1 OR SY-TABIX = 2.
       CONTINUE.
     ENDIF.
   WRITE: / WA_TEMP.
     INSERT INTO ZDSBBR VALUES WA_TEMP.
ENDLOOP.
CLOSE DATASET P_FILE.

It's Unicode not convertible error. If i change ty_pa0002, it wont be able to catch the value from the excel file which converted to CSV.

How can i solve this problem?


TYPES: BEGIN of ty_pa0002,
       DF TYPE CHAR9,
       BBTNO TYPE CHAR4,
       VOL TYPE CHAR11,
       DP TYPE CHAR11,
       AVP TYPE CHAR6,
       VARIANCE TYPE CHAR6,
       RBBT TYPE CHAR6,
       RV TYPE CHAR6,
       STATUS TYPE CHAR31,
END of ty_pa0002.

data: it_final type standard table of ty_pa0002 with header line.
DATA: IT_PA0002 TYPE TABLE OF TY_PA0002 WITH HEADER LINE.
data: it_temp type standard table of ty_pa0002 with header line.
DATA: WA_TEMP TYPE TY_PA0002.
DATA: TEMSTR TYPE CHAR300.

OPEN DATASET FILE_PATH FOR INPUT IN TEXT MODE ENCODING DEFAULT.
DO.
   READ DATASET FILE_PATH INTO TEMSTR.
   IF SY-SUBRC = 0.
     SPLIT TEMSTR AT ',' INTO WA_TEMP-DF WA_TEMP-BBTNO WA_TEMP-VOL WA_TEMP-DP WA_TEMP-AVP WA_TEMP-VARIANCE WA_TEMP-RBBT WA_TEMP-RV WA_TEMP-STATUS.
     APPEND WA_TEMP TO IT_FINAL.
   ELSE.
     EXIT.
   ENDIF.
ENDDO.

CLEAR WA_TEMP.

LOOP AT IT_FINAL INTO WA_TEMP.
     IF SY-TABIX = 1 OR SY-TABIX = 2.
       CONTINUE.
     ENDIF.
   WRITE: / WA_TEMP.
     INSERT INTO ZDSBBR VALUES WA_TEMP.
ENDLOOP.
CLOSE DATASET P_FILE.

3 REPLIES 3
Read only

mayur_priyan
Active Participant
0 Likes
783

Hi,

I am not sure about your problem, though you can try other methods to upload your value into the database table.

INSERT statement within the loop hits the database every time. Its better to delete the unwanted rows from the IT_FINAL table and directly update the ZDSBBR table using MODIFY statement.

MODIFY <dbtable> FROM TABLE <itab>.

Regards,

Mayur Priyan.S

Read only

Former Member
0 Likes
783

Hi,

Maybe there is a mismatch between the field definitions of the file and the definitions of the columns in the table ZDSBBR.

Also try to use Modify statement in the code as mentioned by Mayur.

-Regards,

Ragavan

Read only

RaymondGiuseppi
Active Contributor
0 Likes
783

Use two structures

  • One for upload with only CHAR fields
  • One referencing database table

Once first internal table is uploaded, then use some MOVE-CORRESPONDING statements (*) in a LOOP to fill the second one. Then update database from the second internal table.

e.g. replace

     INSERT INTO ZDSBBR VALUES WA_TEMP.

with


     MOVE-CORRESPONDINF WA_TEMP TO WA_ZDSBBR. " TYPE ZDSBBR

     INSERT INTO ZDSBBR VALUES WA_ZDSBBR.

Of course feel free (**) use a wrapping TRY/ENDTRY to CATCH some wrong data conversion (cx_sy_conversion_error)

Regards,

Raymond

(*) or some conversion exit like CONVERSION_EXIT_ALPHA_INPUT, will depend on domain of fields, and Abap rule for implicit conversion of data.

(**) aka you should/must