‎2008 Nov 23 7:25 AM
when i execute this function i got a error:
"Access via 'NULL' object reference not possible"
what is that mean?
my code is this:
types: begin of ztemp,
text type string,
end of ztemp.
data: itab standard table of ztemp.
call function gui_upload
exporting
filename = 'c:\dana\test.txt'
filetype = 'ASC'
tables
data_tab = itab
exceptions
.
.
.
thank you,
dana
‎2008 Nov 23 7:31 AM
Hi dana,
Basically you have to capture the exceptions. then you will get the correct error.
At that above issue will not come.
Plz try this code.
REPORT YTEST .
DATA: W_TEXTOUT LIKE T100-TEXT.
TYPES: BEGIN OF ZTEMP,
TEXT TYPE STRING,
END OF ZTEMP.
DATA: ITAB TYPE STANDARD TABLE OF ZTEMP.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'c:\dana\test.txt'
FILETYPE = 'ASC'
* HAS_FIELD_SEPARATOR = ' '
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* VIRUS_SCAN_PROFILE =
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
DATA_TAB = ITAB
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
.
IF SY-SUBRC <> 0.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
MSGID = SY-MSGID
MSGNR = SY-MSGNO
MSGV1 = SY-MSGV1
MSGV2 = SY-MSGV2
MSGV3 = SY-MSGV3
MSGV4 = SY-MSGV4
IMPORTING
MESSAGE_TEXT_OUTPUT = W_TEXTOUT.
IF SY-SUBRC = 0.
WRITE W_TEXTOUT.
ENDIF.
ENDIF.Regards,
Anver
Edited by: Anversha s on Nov 23, 2008 1:02 PM
‎2008 Nov 23 7:42 AM
i tried that and its not working because there is a dump.
i run this function in bsp application (hrrcf_app_e_ext)
in class: cl_hrrcf_app_e_ext_appl_data_m
in method: save_attachments
when i run this code in a y_test program its work fine.
maybe its not aloud to execute this program in that method?
is there other function that do the same that meybe i can use?
thank you very much,
dana
‎2008 Nov 24 3:10 AM
Hi,
Use this :
TYPES: BEGIN OF T_TAB,
MATNR LIKE ZMARA-MATNR,
ERSDA LIKE ZMARA-ERSDA,
ERNAM LIKE ZMARA-ERNAM,
END OF T_TAB.
DATA : T_UPLOAD TYPE STANDARD TABLE OF T_TAB WITH HEADER LINE ,
IT_RAW TYPE TRUXS_T_TEXT_DATA. "work table internal table
* Uploading the data in the file into internal table
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
* I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = IT_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = T_UPLOAD[]
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2.
Thanks & Regards,
Krishna..
‎2008 Nov 24 4:10 AM
Hi Dana Touty,
First, enter your records into your excel file and then save as TEXT DELIMITED (save as type).
This will result in a text file with your records.
Now, use this code to upload your text file data into internal table.
Its working.
If you use header for the name of the columns in your excel file then remember to delete the first row from the internal table.
REPORT ZTG_VENDRP
NO STANDARD PAGE HEADING LINE-SIZE 255.
TYPES : BEGIN OF VENDOR,
LIFNR LIKE RF02K-LIFNR,
BUKRS LIKE RF02K-BUKRS,
EKORG LIKE RF02K-EKORG,
KTOKK LIKE RF02K-KTOKK,
ANRED LIKE LFA1-ANRED,
NAME1 LIKE LFA1-NAME1,
SORTL LIKE LFA1-SORTL,
LAND1 LIKE LFA1-LAND1,
SPRAS LIKE LFA1-SPRAS,
WAERS LIKE LFM1-WAERS,
END OF VENDOR.
DATA : VENDOR_TAB TYPE STANDARD TABLE OF VENDOR INITIAL SIZE 10 WITH HEADER LINE.
START-OF-SELECTION.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'c:\vendors.txt'
FILETYPE = 'DAT'
TABLES
DATA_TAB = VENDOR_TAB.
IF SY-SUBRC <> 0.
ENDIF.
This will populate your internal table with all the records.
Now, you can manipulate this data as per your requirements.
Hope this solves your problem.
Regards.
Tarun Gambhir.
‎2008 Nov 24 4:16 AM
Hi,
You are using TXT file to upload the data, Use DAT as filetype in FM instead of ASC.
Try This.
Regards