2008 May 14 12:35 PM
Hi All,
Good Moring,
My task is to update a custom Z-table with respect to the given flatfile. First, I have to upload the flatfile data and then compare & update the Z-table on the basis of the common record.
To do the above task, I have created one internal table for the flatfile data and one more internal table for the Z-table data.
First, I want to compare the both internal tables for the common records, and then, modify the Z-table from the internal table.
Now, I have written the code for comparing the internal tables,
even though there are common records (checked in the debugging mode using the tables option) this Sy-Subrc = 4 always showing 4.
Plesas, give me some use ful hint, I am pasting the code below.........
REPORT ZPPBLORD.
*Tables
TABLES: ZBCTBLORDK, " Blend Orders For Honeywell blending in BCT
ZBCTSTATUS. " BCT - Status code table for blend orders
*Internal Tables
DATA: BEGIN OF IT_DBTAB OCCURS 0,
AUFNR(12), " like zbctblordk-aufnr,
SMARTCRDID(12), " like zbctblordk-smartcrdid,
AEDAT(10), " like zbctblordk-aedat,
AEUHR(8), " like zbctblordk-aeuhr,
STATUS LIKE ZBCTBLORDK-STATUS,
END OF IT_DBTAB.
DATA: BEGIN OF IT_FLFILE OCCURS 0,
AUFNR(12), " like zbctblordk-aufnr,
SMARTCRDID(12), " like zbctblordk-smartcrdid,
AEDAT(10), " like zbctblordk-aedat,
AEUHR(8), " like zbctblordk-aeuhr,
STAT_CODE LIKE ZBCTSTATUS-STAT_CODE,
STAT_TEXT LIKE ZBCTSTATUS-STAT_TEXT,
END OF IT_FLFILE.
START-OF-SELECTION.
SELECT AUFNR
SMARTCRDID
AEDAT
AEUHR
STATUS FROM ZBCTBLORDK INTO TABLE IT_DBTAB.
*Upload data from the specified file to internal table
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = 'P:\ZBCT.TXT'
FILETYPE = 'DAT'
TABLES
DATA_TAB = IT_FLFILE
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TABLE_WIDTH = 4
INVALID_TYPE = 5
NO_BATCH = 6
UNKNOWN_ERROR = 7
OTHERS = 8.
END-OF-SELECTION.
CLEAR: IT_FLFILE, IT_DBTAB.
BREAK-POINT.
LOOP AT IT_DBTAB.
READ TABLE IT_FLFILE WITH KEY AUFNR = IT_DBTAB-AUFNR
SMARTCRDID = IT_DBTAB-SMARTCRDID.
IF SY-SUBRC = 0.* SY-SUBRC always showing 4, and getting in-side
I want to use Modify internal table command here
WRITE:/ IT_DBTAB-AUFNR,
IT_DBTAB-SMARTCRDID,
IT_DBTAB-AEDAT,
IT_DBTAB-AEUHR,
IT_DBTAB-STATUS.
ENDIF.
ENDLOOP.
ENDLOOP.
2008 May 14 1:16 PM
Hi,
In Debugging, check the values populated in IT_DBTAB-AUFNR and IT_DBTAB-SMARTCRDID.
If leading zeros are not added, then use this Function Module to add leading zeros.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = it_dbtab-aufnr.
importing
output = it_dbtab-aufnr.
Regards
Sandeep Reddy.
Hi All,
Good Moring,
My task is to update a custom Z-table with respect to the given flatfile. First, I have to upload the flatfile data and then compare & update the Z-table on the basis of the common record.
To do the above task, I have created one internal table for the flatfile data and one more internal table for the Z-table data.
First, I want to compare the both internal tables for the common records, and then, modify the Z-table from the internal table.
Now, I have written the code for comparing the internal tables,
even though there are common records (checked in the debugging mode using the tables option) this Sy-Subrc = 4 always showing 4.
Plesas, give me some use ful hint, I am pasting the code below.........
REPORT ZPPBLORD.
*Tables
TABLES: ZBCTBLORDK, " Blend Orders For Honeywell blending in BCT
ZBCTSTATUS. " BCT - Status code table for blend orders
*Internal Tables
DATA: BEGIN OF IT_DBTAB OCCURS 0,
AUFNR(12), " like zbctblordk-aufnr,
SMARTCRDID(12), " like zbctblordk-smartcrdid,
AEDAT(10), " like zbctblordk-aedat,
AEUHR(8), " like zbctblordk-aeuhr,
STATUS LIKE ZBCTBLORDK-STATUS,
END OF IT_DBTAB.
DATA: BEGIN OF IT_FLFILE OCCURS 0,
AUFNR(12), " like zbctblordk-aufnr,
SMARTCRDID(12), " like zbctblordk-smartcrdid,
AEDAT(10), " like zbctblordk-aedat,
AEUHR(8), " like zbctblordk-aeuhr,
STAT_CODE LIKE ZBCTSTATUS-STAT_CODE,
STAT_TEXT LIKE ZBCTSTATUS-STAT_TEXT,
END OF IT_FLFILE.
START-OF-SELECTION.
SELECT AUFNR
SMARTCRDID
AEDAT
AEUHR
STATUS FROM ZBCTBLORDK INTO TABLE IT_DBTAB.
*Upload data from the specified file to internal table
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = 'P:\ZBCT.TXT'
FILETYPE = 'DAT'
TABLES
DATA_TAB = IT_FLFILE
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TABLE_WIDTH = 4
INVALID_TYPE = 5
NO_BATCH = 6
UNKNOWN_ERROR = 7
OTHERS = 8.
END-OF-SELECTION.
CLEAR: IT_FLFILE, IT_DBTAB.
BREAK-POINT.
LOOP AT IT_DBTAB.
READ TABLE IT_FLFILE WITH KEY AUFNR = IT_DBTAB-AUFNR
SMARTCRDID = IT_DBTAB-SMARTCRDID.
IF SY-SUBRC = 0.* SY-SUBRC always showing 4, and getting in-side
I want to use Modify internal table command here
WRITE:/ IT_DBTAB-AUFNR,
IT_DBTAB-SMARTCRDID,
IT_DBTAB-AEDAT,
IT_DBTAB-AEUHR,
IT_DBTAB-STATUS.
ENDIF.
ENDLOOP.
ENDLOOP.
2008 May 14 12:44 PM
Hi,
1.First upload the records from flat file to Internal table.
2.Then INSERT/MODIFY the records into the Ztable.
Check:
REPORT zmat_no message-id zebg.
TYPE-POOLS truxs.
TABLES:zmatnr.
DATA : itab LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.
DATA row LIKE alsmex_tabline-row.
data : g_matnr like mara-matnr.
data : count type i.
data : itab_count type i.
data : gi_final like zmatnr occurs 0 with header line.
*data : begin of gi_final occurs 0,
mat_old like mara-matnr,
mat_new like mara-matnr,
end of gi_final.
***********************Selection Screen*************************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETER : pfname LIKE rlgrap-filename OBLIGATORY.
select-options : records for count.
SELECTION-SCREEN END OF BLOCK b1.
*******************************************************************
*********************At Selection Screen*************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pfname.
PERFORM search.
*******************************************************************
START-OF-SELECTION.
perform process.
form process.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = pfname
i_begin_col = 1
i_begin_row = 2
i_end_col = 12
i_end_row = 65000
TABLES
intern = itab
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.
describe table itab lines itab_count.
row = 1.
loop at itab.
if itab-row row.
append gi_final.
clear gi_final.
endif.
case itab-col.
when '1'.
CLEAR G_MATNR.
gi_final-OLD_MATNR = itab-value.
CONCATENATE 'NEW' gi_final-old_matnr INTO itab-value.
gi_final-new_MATNR = itab-value.
endcase.
row = itab-row.
append gi_final.
clear gi_final.
endloop.
CALL FUNCTION 'PROGRESS_INDICATOR'
EXPORTING
I_TEXT = 'File Has Been Successfully Uploaded from Workstation ' .
if not gi_final[] is initial.
if not records-low is initial .
if not records-high is initial.
records-high = records-high + 1.
DESCRIBE TABLE gi_final LINES count.
IF records-high < count.
DELETE gi_final FROM records-high TO count.
ENDIF.
IF records-low <> 1.
IF records-low 0.
DELETE gi_final FROM 1 TO records-low.
ENDIF.
ENDIF.
endif.
endif.
endif.
IF NOT GI_FINAL[] IS INITIAL.
CALL FUNCTION 'PROGRESS_INDICATOR'
EXPORTING
I_TEXT = 'Processing zmatnr table'
I_OUTPUT_IMMEDIATELY = 'X'.
if itab_count count.
*
message i000 with 'records are not matching'.
*
exit.
*
else.
modify zmatnr from table gi_final.
message i000 with 'data base table modified successfully'.
endif.
endif.
endform.
&----
*& Form search
&----
text
-
--> p1 text
<-- p2 text
-
FORM search .
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
static = 'X'
CHANGING
file_name = pfname.
ENDFORM. " search
Regards,
Shiva.
2008 May 14 12:47 PM
Hi ,
The 2 internal tables don't seem to have a similar structure . Please check how you are comparing . And the fields you are comparing have similar domain ?
Regards,
Deepthi
2008 May 14 12:50 PM
Hi,
Does the IT_FLFILE-AUFNR have leading zeros?
Try this.
WS_UPLOAD or GUI_UPLOAD.
SELECT AUFNR
SMARTCRDID
AEDAT
AEUHR
STATUS FROM ZBCTBLORDK INTO TABLE IT_DBTAB
for all entries in it_flfile
where AUFNR = IT_flfile-AUFNR
SMARTCRDID = IT_flfile-SMARTCRDID.
sort it_dbtab.
loop at it_flfile.
read table it_dbtab with key AUFNR = IT_flfile-AUFNR
SMARTCRDID = IT_flfile-SMARTCRDID.
if sy-subrc <> 0.
delete it_flfile.
endif.
endllop.
update table ZBCTBLORDK from it_flfile.
Cheers.
...Reward if useful.
2008 May 14 1:13 PM
hi,
Is your problem solved with the above given solution...
or else just message back...
i have done a similar requirement..i can help you...
Cheers..,
Trinath.
2008 May 14 1:24 PM
Hi all,
Thanks for quick response.
Trinath, I have just tried with the I Wong's solution, still the IT_DBTAB is not populating with the records.
Please, send your solution.
Thanks in advance.
KalChand
2008 May 14 1:16 PM
Hi,
In Debugging, check the values populated in IT_DBTAB-AUFNR and IT_DBTAB-SMARTCRDID.
If leading zeros are not added, then use this Function Module to add leading zeros.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = it_dbtab-aufnr.
importing
output = it_dbtab-aufnr.
Regards
Sandeep Reddy.
2008 May 14 1:27 PM
Hi Sudeep,
I have found in the debugging that IT_DBTAB got populated with the records,
But while modifying, it's giving error (SY-SUBRC = 4).
there are no leading zeros......
Thanks.
KC
2008 May 14 2:02 PM
Hi
This is not the conventional way of storing the data into an internal table.
First of all you have to SPLIT IT_FLFILE and store in a structured Internal table. And then READ.
Otherwise in the debug mode, make sure the values are stored into correspoding fields of IT_FLFILE. Sometimes It will be messed up.
2008 May 14 5:00 PM
Hi All,
I got problem because of "LEADING ZEROS" as sudeep said.
It's solved now.
Thanks for your help,
KC