2012 May 09 12:50 PM
Dear Friends,
I am uploading excel file.. it is uploading well.
But the last fields are not getting updated
Previous it was uploaded well.. i really wondered why it is not working now.
It has totally 10 fields 9th field is some value(like 45.25) and last colun is text field.
Kindly help me please.
Dear Friends,
I am uploading excel file.. it is uploading well.
But the last fields are not getting updated
Previous it was uploaded well.. i really wondered why it is not working now.
It has totally 10 fields 9th field is some value(like 45.25) and last colun is text field.
Kindly help me please.
2012 May 09 1:37 PM
Hi Anurag,
In the driver program, there might be FM ALSM_EXCEL_TO_INTERNAL_TABLE.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename =
i_begin_col =
i_begin_row = "Update
i_end_col =
i_end_row =
tables
intern = gt_return
* EXCEPTIONS
* INCONSISTENT_PARAMETERS = 1
* UPLOAD_OLE = 2
* OTHERS = 3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
So you have to modify end row , end col as per your excel shhet columns.Also you have to modify the table contents inside the loop for that particular column.
Eg:
case gt_return -col.
when '0001'.
w_record-matnr = gt_return -value.
when '0002'. "Add ur col number and
w_record-mtart = gt_return -value. "Change field name
endcase.
Finally while displaing, depending upaonm Simaple /AlV report , you have to modify write stmt or Fieldcatalog .
2012 May 10 6:39 AM
DATA: BEGIN OF l_intern OCCURS 0.
INCLUDE STRUCTURE alsmex_tabline.
DATA: END OF l_intern.
TYPES : BEGIN OF gt_sdtab ,
lifnr like LFBW-lifnr,
bukrs like LFBW-bukrs,
witht like LFBW-witht,
END OF gt_sdtab.
DATA : itab TYPE STANDARD TABLE OF gt_sdtab WITH HEADER LINE.
PERFORM upload_file TABLES itab USING p_file.
FORM upload_file TABLES p_it_tab USING p_file.
FIELD-SYMBOLS : <fs>.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_file
i_begin_col = '1'
i_begin_row = '2'
i_end_col = '256'
i_end_row = '10000'
TABLES
intern = l_intern
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc NE 0.
FORMAT COLOR COL_BACKGROUND INTENSIFIED.
WRITE : / 'File Error'.
EXIT.
ENDIF.
IF l_intern[] IS INITIAL.
FORMAT COLOR COL_BACKGROUND INTENSIFIED.
WRITE : / 'No Data Uploaded'.
EXIT.
ELSE.
SORT l_intern BY row col.
LOOP AT l_intern.
MOVE l_intern-col TO l_index.
ASSIGN COMPONENT l_index OF STRUCTURE p_it_tab TO <fs>.
MOVE l_intern-value TO <fs>.
AT END OF row.
APPEND p_it_tab.
CLEAR p_it_tab.
ENDAT.
ENDLOOP.
ENDIF.
ENDFORM.
2012 May 10 6:51 AM
Hi, Anurag.
you may use following code
DATA : ITAB LIKE ALSMEX_TABLINE OCCURS 10 WITH HEADER LINE.
PARAMETERS : PA_FILE TYPE RLGRAP-FILENAME OBLIGATORY,
P_SES_NM TYPE APQI-GROUPID OBLIGATORY,
START TYPE I,
END TYPE I.
PERFORM GET_FILE USING START END.
FORM GET_FILE USING P_START P_END.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = PA_FILE
I_BEGIN_COL = 1
I_BEGIN_ROW = P_START
I_END_COL = 256
I_END_ROW = P_END
TABLES
INTERN = ITAB.
SORT ITAB BY ROW COL.
LOOP AT ITAB.
CASE ITAB-COL.
WHEN '0001'. WA_DATA-MATNR = ITAB-VALUE.
.
.
.
.
WHEN 'XXXX'. WA_DATA-XXXXX = ITAB-VALUE. " it's your last coloumn in excel sheet
ENDCASE.
AT END OF ROW.
APPEND WA_DATA TO IT_DATA.
CLEAR WA_DATA.
ENDAT.
ENDLOOP.
ENDFORM. " GET_FILE
you should declear WA_DATA and IT_DATA as per your requirement.
I hope this code may solve your problem.
if not then feel free to ask me.
2012 May 10 1:17 PM
Hi Anurag,
To identify the reason for the last field not having values, you need to add the following info:
1. The FM you've used in your code.
2. It is always recommended to use a tab delimited text file to upload data rather than an excel file due to auto conversion of values in excel.
3. Verify if your last column text data has any special characters like ',",!,#, etc. These characters will reflect the data truncation in debug mode in the internal table of your code.
Hope this helps! If still facing any issues, do reply.
Regards, Pranav.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |