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

Urgent

Former Member
0 Likes
1,629

Hi Patric Yee,

Thank very much for your help

table is uploded from internal table

now i want to display in output

How many Records Updated &

How many records Duplicate or error

i used foloowing logic

i got output what are records in itab that show as updated records

and

no error records

please see my code let me the modification to get desired result

advanced thanks to your reply

tables : ztable.

TYPE-POOLS: SLIS.

data: fieldcatalog type slis_t_fieldcat_alv with header line,

header type slis_t_listheader,

gd_layout type slis_layout_alv,

wa type slis_listheader.

data : nlinechar(20) type c, rows type i, tabcount type i.

data : begin of itab occurs 100.

include structure zpcard.

data : end of itab.

data : begin of itabs occurs 100.

include structure zpcard.

data : end of itabs.

data : begin of itabe occurs 100.

include structure zpcard.

data : end of itabe.

selection-screen: begin of block sel with frame title text-sel.

parameters: p_file type rlgrap-filename

selection-screen: end of block sel.

at selection-screen on value-request for p_file.

call function 'F4_FILENAME'

EXPORTING

field_name = 'p_file'

IMPORTING

file_name = p_file.

start-of-selection.

call function 'WS_UPLOAD'

exporting

filename = p_file

filetype = 'DAT'

tables

data_tab = itab

exceptions

others = 10.

clear : itab, itabs, itabe.

sort itab by inter_audit_cd.

loop at itab.

ztable-mandt = sy-mandt.

modify itab transporting mandt.

check not itab[] is initial.

if sy-subrc eq 0.

modify ztable from table itab.

move-corresponding itab to itabs.

append itabs.

clear itabs.

else.

select single * from ztable

where inter_audit_cd eq itab-inter_audit_cd.

move-corresponding itab to itabe.

append itabe.

clear itabe.

delete itab.

clear itab.

endif.

endloop.

*----


if sy-subrc eq 0.

commit work.

else.

rollback work.

endif.

perform disp_rpt.

*----


*Display Error File Data

*----


form disp_rpt.

fieldcatalog-fieldname = 'MANDT'.

fieldcatalog-seltext_l = 'MANDT'.

fieldcatalog-col_pos = 0.

fieldcatalog-emphasize = 'X'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'INTER_AUDIT_CD'.

fieldcatalog-seltext_l = 'COST CENTER'.

fieldcatalog-col_pos = 1.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'TRAN_DATE'.

fieldcatalog-seltext_l = 'TRANSACTION DATE'.

fieldcatalog-col_pos = 2.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'POSTING_DATE'.

fieldcatalog-seltext_l = 'POSTING DATE'.

fieldcatalog-col_pos = 3.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'TRAN_AMT'.

fieldcatalog-seltext_l = 'TRANSACTION AMOUNT'.

fieldcatalog-col_pos = 4.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'CURR_KEY'.

fieldcatalog-seltext_l = 'CURRENCY KEY'.

fieldcatalog-col_pos = 5.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'DEBIT_CREDIT'.

fieldcatalog-seltext_l = 'DEBIT CREDIT KEY'.

fieldcatalog-col_pos = 6.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'UPLOAD_DATE'.

fieldcatalog-seltext_l = 'UPLOAD DATE'.

fieldcatalog-col_pos = 1.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = 'Zprg'

i_callback_top_of_page = 'TOP_OF_PAGE1'

it_fieldcat = fieldcatalog[]

i_save = 'A'

tables

t_outtab = ITABe.

endform. " Disp_rpt

*----


  • PAGE HEADERS IN ALV REPORT

*----


form top_of_page1.

wa-typ = 'S'.

describe table itabs lines rows.

rows = sy-tfill.

nlinechar = rows.

concatenate nlinechar text-002 into

wa-info separated by space.

append wa to header.

wa-typ = 'S'.

describe table itabe lines rows.

rows = sy-tfill.

nlinechar = rows.

concatenate nlinechar text-001 into

wa-info separated by space.

append wa to header.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = header.

clear: header, header[].

endform.

i look forward to your reply

Regards

Raja Sekhar.T

1 ACCEPTED SOLUTION
Read only

former_member221770
Contributor
0 Likes
1,587

Raja,

I have a bit trouble following what you are trying to do. Let me go through what I THINK you are trying to do:

You have a table ITAB. ITABS are the successful changes. ITABE are the errors (if the record already exists in ZTABLE it is considered an error).

So here is how I would do it. Take out you code from

"loop at itab" all the way to "perform disp_rpt" and replace with:

  • Get all the records that already exist in ZTABLE into

  • ITABE

select *

into table itabe

from ztable

for all entries in itab

where inter_audit_cd = itab-inter_audit_cd.

  • Prepare for Binary Search

sort itabe by inter_audit_cd.

loop at itab.

  • Check to see if ITAB record exists in ITABE

read table itabe with key inter_audit_cd =

itab-inter_audit_cd

binary search.

if sy-subrc eq 0.

  • Record exists, delete the record from ITAB

delete itab.

else.

  • Record does not exist in ZTABLE, insert the Client

  • Number

itab-mandt = sy-mandt.

modify itab transporting mandt.

endif.

endloop.

  • Now ITAB will only have records that do not exist in

  • ZTABLE, while ITABE will have records that exist in

  • ZTABLE. Time to update ZTABLE

if not itab[] is initial.

modify ztable from table itab.

if sy-subrc eq 0.

  • Records Updated

commit work.

else.

  • Update failed - move the records inITAB to ITABE

rollback work.

loop at itab.

itabe = itab.

append itabe.

endloop.

refresh itab.

endif.

endif.

  • Now ITABE will have the records that exist in ZTABLE and

  • the records that failed the MODIFY. And ITAB contains

  • the records that were updated into ZTABLE.

perform disp_rpt.

Also make sure when you specify your CALLBACK PROGRAM parameter in your ALV FM you use upper case.

Hope this helps.

Cheers,

Pat.

PS.Kindly assign Reward Points if you found this post helpful.

Hi Patric Yee,

Thank very much for your help

table is uploded from internal table

now i want to display in output

How many Records Updated &

How many records Duplicate or error

i used foloowing logic

i got output what are records in itab that show as updated records

and

no error records

please see my code let me the modification to get desired result

advanced thanks to your reply

tables : ztable.

TYPE-POOLS: SLIS.

data: fieldcatalog type slis_t_fieldcat_alv with header line,

header type slis_t_listheader,

gd_layout type slis_layout_alv,

wa type slis_listheader.

data : nlinechar(20) type c, rows type i, tabcount type i.

data : begin of itab occurs 100.

include structure zpcard.

data : end of itab.

data : begin of itabs occurs 100.

include structure zpcard.

data : end of itabs.

data : begin of itabe occurs 100.

include structure zpcard.

data : end of itabe.

selection-screen: begin of block sel with frame title text-sel.

parameters: p_file type rlgrap-filename

selection-screen: end of block sel.

at selection-screen on value-request for p_file.

call function 'F4_FILENAME'

EXPORTING

field_name = 'p_file'

IMPORTING

file_name = p_file.

start-of-selection.

call function 'WS_UPLOAD'

exporting

filename = p_file

filetype = 'DAT'

tables

data_tab = itab

exceptions

others = 10.

clear : itab, itabs, itabe.

sort itab by inter_audit_cd.

loop at itab.

ztable-mandt = sy-mandt.

modify itab transporting mandt.

check not itab[] is initial.

if sy-subrc eq 0.

modify ztable from table itab.

move-corresponding itab to itabs.

append itabs.

clear itabs.

else.

select single * from ztable

where inter_audit_cd eq itab-inter_audit_cd.

move-corresponding itab to itabe.

append itabe.

clear itabe.

delete itab.

clear itab.

endif.

endloop.

*----


if sy-subrc eq 0.

commit work.

else.

rollback work.

endif.

perform disp_rpt.

*----


*Display Error File Data

*----


form disp_rpt.

fieldcatalog-fieldname = 'MANDT'.

fieldcatalog-seltext_l = 'MANDT'.

fieldcatalog-col_pos = 0.

fieldcatalog-emphasize = 'X'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'INTER_AUDIT_CD'.

fieldcatalog-seltext_l = 'COST CENTER'.

fieldcatalog-col_pos = 1.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'TRAN_DATE'.

fieldcatalog-seltext_l = 'TRANSACTION DATE'.

fieldcatalog-col_pos = 2.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'POSTING_DATE'.

fieldcatalog-seltext_l = 'POSTING DATE'.

fieldcatalog-col_pos = 3.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'TRAN_AMT'.

fieldcatalog-seltext_l = 'TRANSACTION AMOUNT'.

fieldcatalog-col_pos = 4.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'CURR_KEY'.

fieldcatalog-seltext_l = 'CURRENCY KEY'.

fieldcatalog-col_pos = 5.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'DEBIT_CREDIT'.

fieldcatalog-seltext_l = 'DEBIT CREDIT KEY'.

fieldcatalog-col_pos = 6.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'UPLOAD_DATE'.

fieldcatalog-seltext_l = 'UPLOAD DATE'.

fieldcatalog-col_pos = 1.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = 'Zprg'

i_callback_top_of_page = 'TOP_OF_PAGE1'

it_fieldcat = fieldcatalog[]

i_save = 'A'

tables

t_outtab = ITABe.

endform. " Disp_rpt

*----


  • PAGE HEADERS IN ALV REPORT

*----


form top_of_page1.

wa-typ = 'S'.

describe table itabs lines rows.

rows = sy-tfill.

nlinechar = rows.

concatenate nlinechar text-002 into

wa-info separated by space.

append wa to header.

wa-typ = 'S'.

describe table itabe lines rows.

rows = sy-tfill.

nlinechar = rows.

concatenate nlinechar text-001 into

wa-info separated by space.

append wa to header.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = header.

clear: header, header[].

endform.

i look forward to your reply

Regards

Raja Sekhar.T

11 REPLIES 11
Read only

Former Member
0 Likes
1,587

Hi

You can use a event like END_OF_LIST where you write how many records are updated, duplicated or error.

But there is some errors in your code:

loop at itab.

  • This statament is useless, the mandt is automatically

inserted by system

ztable-mandt = sy-mandt.

modify itab transporting mandt.

  • This control is useless, you are in loop of your

  • table, so it means there are records in it, you should

  • place this control out of loop/endloop

check not itab[] is initial.

  • This control is useless, sy-subrc is always 0, because

  • statament MODIFY ITAB is successfully done

if sy-subrc eq 0.

  • This statament is wrong: you are updating the table

  • ZTABLE with all records in ITAB in only one time, but * you repeat this action for each record in ITAB. So if * you have 100 records, in the first loop you update

  • ZTABLE for all 100 records, in the second loop you

  • update for all 100 records too, and so...

ERROR-----> modify ztable from table itab.

  • You should write:

modify ztable from itab.

move-corresponding itab to itabs.

append itabs.

clear itabs.

  • If you want to know how many records you have update

modify ztable from itab.

count_modify = count_modify + 1.

  • I can't understand what you want to do here, because I understand your IF control:

else.

select single * from ztable

where inter_audit_cd eq itab-inter_audit_cd.

move-corresponding itab to itabe.

append itabe.

clear itabe.

delete itab.

clear itab.

endif.

endloop.

Max

Read only

0 Likes
1,587

Hi Max binchi,

thank u very much ur help

i want to display no of records updated in table from itab

and no of error or duplicate record display in output and display record of error or duplicate

During updates of new record, Z_PCARD_UPLOAD runs the program however, ZPCARD table doesn't remove old records and update with new records.

In upload program, can you place a check (for each field) to make sure the uploading data is "clean" (eg. Formats, etc)? SAP has standard check however, it gives ABAP dump. Instead of system dump, I would like the program to display the line item with "unclean" data.

Please see the code and let me know the modification

iam very much tahnkful to u , this is urgent

advanced thanks to u

i look forward to ur reply

tables : zpcard.

TYPE-POOLS: SLIS.

data: fieldcatalog type slis_t_fieldcat_alv with header line,

header type slis_t_listheader,

gd_layout type slis_layout_alv,

wa type slis_listheader.

field-symbols : <FS>.

data : l_index type i.

data : nlinechar(20) type c, rows type i, tabcount type i.

data : begin of itab occurs 100.

include structure ztable.

data : end of itab.

data : begin of itabs occurs 100.

include structure ztable.

data : end of itabs.

data : begin of itabe occurs 100.

include structure ztable.

data : end of itabe.

selection-screen: begin of block sel with frame title text-sel.

parameters: p_file type rlgrap-filename.

selection-screen: end of block sel.

at selection-screen on value-request for p_file.

call function 'F4_FILENAME'

EXPORTING

field_name = 'p_file'

IMPORTING

file_name = p_file.

start-of-selection.

call function 'WS_UPLOAD'

exporting

filename = p_file

filetype = 'DAT'

tables

data_tab = itab

exceptions

others = 10.

select * from zpcard into table itabe

for all entries in itab

where inter_audit_cd eq itab-inter_audit_cd.

sort itabe by inter_audit_cd.

loop at itab.

if itab-inter_audit_cd is initial.

*message i001.

stop.

endif.

CLEaR L_INDEX.

DO.

L_INDEX = L_INDEX + 1.

ASSIGN COMPONENT L_INDEX OF STRUCTURE ITAB TO <fs>.

IF SY-SUBRC NE 0.

EXIT.

ELSE.

TRANSLATE <FS> TO UPPER CASE.

endif.

ENDDO.

read table itabe with key

inter_audit_cd = itab-inter_audit_cd binary search.

if sy-subrc eq 0.

delete from zpcard where inter_audit_cd eq itabe-inter_audit_cd.

else.

itab-mandt = sy-mandt.

modify itab transporting mandt.

endif.

endloop.

if not itab[] is initial.

modify zpcard from table itab.

if sy-subrc eq 0.

commit work.

else.

rollback work.

loop at itab.

itab_e = itab.

append itabe.

endloop.

refresh itab.

endif.

endif.

perform disp_rpt.

*----


*Display Error File Data

*----


form disp_rpt.

fieldcatalog-fieldname = 'MANDT'.

fieldcatalog-seltext_l = 'MANDT'.

fieldcatalog-col_pos = 0.

fieldcatalog-emphasize = 'X'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'INTER_AUDIT_CD'.

fieldcatalog-seltext_l = 'COST CENTER'.

fieldcatalog-col_pos = 1.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'TRAN_DATE'.

fieldcatalog-seltext_l = 'TRANSACTION DATE'.

fieldcatalog-col_pos = 2.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'POSTING_DATE'.

fieldcatalog-seltext_l = 'POSTING DATE'.

fieldcatalog-col_pos = 3.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'TRAN_AMT'.

fieldcatalog-seltext_l = 'TRANSACTION AMOUNT'.

fieldcatalog-col_pos = 4.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'CURR_KEY'.

fieldcatalog-seltext_l = 'CURRENCY KEY'.

fieldcatalog-col_pos = 5.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'DEBIT_CREDIT'.

fieldcatalog-seltext_l = 'DEBIT CREDIT KEY'.

fieldcatalog-col_pos = 6.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'UPLOAD_DATE'.

fieldcatalog-seltext_l = 'UPLOAD DATE'.

fieldcatalog-col_pos = 1.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = 'Z_PCARD_UPLOAD'

i_callback_top_of_page = 'TOP_OF_PAGE1'

it_fieldcat = fieldcatalog[]

i_save = 'A'

tables

t_outtab = ECARD.

endform. " Disp_rpt

*----


  • PAGE HEADERS IN ALV REPORT

*----


form top_of_page1.

wa-typ = 'S'.

describe table itabe lines rows.

rows = sy-tfill.

nlinechar = rows.

concatenate nlinechar text-001 into

wa-info separated by space.

append wa to header.

wa-typ = 'S'.

describe table itabs lines rows.

rows = sy-tfill.

nlinechar = rows.

concatenate nlinechar text-002 into

wa-info separated by space.

append wa to header.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = header.

clear: header, header[].

endform.

regards

Raja Sekhar

Read only

0 Likes
1,587

Hi

You can use two internal table (one for updating and one for inserting) as zpcard.

I don't know how ZTABLE is, so you can use statament MOVE-CORRESPONDING to convert automatically the data:

read table itabe with key

inter_audit_cd = itab-inter_audit_cd binary search.

if sy-subrc eq 0.

delete from zpcard where inter_audit_cd eq

itabe-inter_audit_cd.

MOVE-CORRESPONDING ITAB TO ITAB_OLD.

else.

itab-mandt = sy-mandt.

modify itab transporting mandt.

MOVE-CORRESPONDING ITAB TO ITAB_OLD.

endif.

After instea of MODIFY ZCARD FROM TABLE

INSERT ZCARD FROm ITAB_NEW.

UPDATE ZCARD FROM ITAB_OLD.

But I can't understand because you want to delete old record before and what DUPLICATE and ERROR mean for you

Max

Read only

0 Likes
1,587

Hi max bianchi

Thank u for ur reply

Upload record should not amend the existing data.It should always clear the existing records in the table

During updates of new record, Zprogram runs the program however, ZPCARD table doesn't remove old records and update with new records.

validation part

Before uploading to the table, check to make sure that the data are clean. Make sure that the format of each record is correct. (eg. Not blank space. If capital letter is required for upload, check the data in .txt file to make sure the records for the field are in Caps, Etc.)

to Validate all internal fields and covert all data into upper case

Please help me

advanced tahnks to ur reply

Regards

Raja Sekhar.T

Read only

0 Likes
1,587

Hi

I can't understand if a record there is ITAB and in ZPCARD should be deleted, updated or not updated.

Look at the code:

read table itabe with key

inter_audit_cd = itab-inter_audit_cd binary search.

if sy-subrc eq 0.

  • Here you are deleting old record

delete from zpcard where inter_audit_cd eq

itabe-inter_audit_cd.

  • Here it's storing new data of old record

MOVE-CORRESPONDING ITAB TO ITAB_OLD.

else.

  • Here it's storing new data of new record

MOVE-CORRESPONDING ITAB TO ITAB_NEW.

endif.

Now there aren't old record in ZPCARD, so if you want to insert only new record:

INSERT ZPCARD FROM TABLE ITAB_NEW.

But if you don't want to delete and update old record, then code should be:

read table itabe with key

inter_audit_cd = itab-inter_audit_cd binary search.

if sy-subrc eq 0.

  • Here you are deleting old record

  • delete from zpcard where inter_audit_cd eq

  • itabe-inter_audit_cd.

  • Here it's storing new data of old record

MOVE-CORRESPONDING ITAB TO ITAB_OLD.

else.

  • Here it's storing new data of new record

MOVE-CORRESPONDING ITAB TO ITAB_NEW.

endif.

INSERT ZPCARD FROM TABLE ITAB_NEW.

But if you want update old record, then code should be:

read table itabe with key

inter_audit_cd = itab-inter_audit_cd binary search.

if sy-subrc eq 0.

  • Here you are deleting old record

  • delete from zpcard where inter_audit_cd eq

  • itabe-inter_audit_cd.

  • Here it's storing new data of old record

MOVE-CORRESPONDING ITAB TO ITAB_OLD.

else.

  • Here it's storing new data of new record

MOVE-CORRESPONDING ITAB TO ITAB_NEW.

endif.

INSERT ZPCARD FROM TABLE ITAB_NEW.

UPDATE ZPCARD FROM TABLE ITAB_OLD.

While looping ITAB you should do your control.

Max

Read only

0 Likes
1,587

Raja,

Has this issue been resolved. If so kindly assign Reward Points and close the thread. Otherwise please get back to us with any other issues.

Cheers,

Pat.

Read only

former_member221770
Contributor
0 Likes
1,588

Raja,

I have a bit trouble following what you are trying to do. Let me go through what I THINK you are trying to do:

You have a table ITAB. ITABS are the successful changes. ITABE are the errors (if the record already exists in ZTABLE it is considered an error).

So here is how I would do it. Take out you code from

"loop at itab" all the way to "perform disp_rpt" and replace with:

  • Get all the records that already exist in ZTABLE into

  • ITABE

select *

into table itabe

from ztable

for all entries in itab

where inter_audit_cd = itab-inter_audit_cd.

  • Prepare for Binary Search

sort itabe by inter_audit_cd.

loop at itab.

  • Check to see if ITAB record exists in ITABE

read table itabe with key inter_audit_cd =

itab-inter_audit_cd

binary search.

if sy-subrc eq 0.

  • Record exists, delete the record from ITAB

delete itab.

else.

  • Record does not exist in ZTABLE, insert the Client

  • Number

itab-mandt = sy-mandt.

modify itab transporting mandt.

endif.

endloop.

  • Now ITAB will only have records that do not exist in

  • ZTABLE, while ITABE will have records that exist in

  • ZTABLE. Time to update ZTABLE

if not itab[] is initial.

modify ztable from table itab.

if sy-subrc eq 0.

  • Records Updated

commit work.

else.

  • Update failed - move the records inITAB to ITABE

rollback work.

loop at itab.

itabe = itab.

append itabe.

endloop.

refresh itab.

endif.

endif.

  • Now ITABE will have the records that exist in ZTABLE and

  • the records that failed the MODIFY. And ITAB contains

  • the records that were updated into ZTABLE.

perform disp_rpt.

Also make sure when you specify your CALLBACK PROGRAM parameter in your ALV FM you use upper case.

Hope this helps.

Cheers,

Pat.

PS.Kindly assign Reward Points if you found this post helpful.

Read only

0 Likes
1,587

Hi Patric Yee,

thank u very much ur help

i want to display no of records updated in table from itab

and no of error or duplicate record display in output and display record of error or duplicate

During updates of new record, Z_PCARD_UPLOAD runs the program however, ZPCARD table doesn't remove old records and update with new records.

In upload program, can you place a check (for each field) to make sure the uploading data is "clean" (eg. Formats, etc)? SAP has standard check however, it gives ABAP dump. Instead of system dump, I would like the program to display the line item with "unclean" data.

Please see the code and let me know the modification

iam very much tahnkful to u , this is urgent

advanced thanks to u

i look forward to ur reply

tables : zpcard.

TYPE-POOLS: SLIS.

data: fieldcatalog type slis_t_fieldcat_alv with header line,

header type slis_t_listheader,

gd_layout type slis_layout_alv,

wa type slis_listheader.

field-symbols : <FS>.

data : l_index type i.

data : nlinechar(20) type c, rows type i, tabcount type i.

data : begin of itab occurs 100.

include structure ztable.

data : end of itab.

data : begin of itabs occurs 100.

include structure ztable.

data : end of itabs.

data : begin of itabe occurs 100.

include structure ztable.

data : end of itabe.

selection-screen: begin of block sel with frame title text-sel.

parameters: p_file type rlgrap-filename.

selection-screen: end of block sel.

at selection-screen on value-request for p_file.

call function 'F4_FILENAME'

EXPORTING

field_name = 'p_file'

IMPORTING

file_name = p_file.

start-of-selection.

call function 'WS_UPLOAD'

exporting

filename = p_file

filetype = 'DAT'

tables

data_tab = itab

exceptions

others = 10.

select * from zpcard into table itabe

for all entries in itab

where inter_audit_cd eq itab-inter_audit_cd.

sort itabe by inter_audit_cd.

loop at itab.

if itab-inter_audit_cd is initial.

*message i001.

stop.

endif.

CLEaR L_INDEX.

DO.

L_INDEX = L_INDEX + 1.

ASSIGN COMPONENT L_INDEX OF STRUCTURE ITAB TO <fs>.

IF SY-SUBRC NE 0.

EXIT.

ELSE.

TRANSLATE <FS> TO UPPER CASE.

endif.

ENDDO.

read table itabe with key

inter_audit_cd = itab-inter_audit_cd binary search.

if sy-subrc eq 0.

delete from zpcard where inter_audit_cd eq itabe-inter_audit_cd.

else.

itab-mandt = sy-mandt.

modify itab transporting mandt.

endif.

endloop.

if not itab[] is initial.

modify zpcard from table itab.

if sy-subrc eq 0.

commit work.

else.

rollback work.

loop at itab.

itab_e = itab.

append itabe.

endloop.

refresh itab.

endif.

endif.

perform disp_rpt.

*----


*Display Error File Data

*----


form disp_rpt.

fieldcatalog-fieldname = 'MANDT'.

fieldcatalog-seltext_l = 'MANDT'.

fieldcatalog-col_pos = 0.

fieldcatalog-emphasize = 'X'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'INTER_AUDIT_CD'.

fieldcatalog-seltext_l = 'COST CENTER'.

fieldcatalog-col_pos = 1.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'TRAN_DATE'.

fieldcatalog-seltext_l = 'TRANSACTION DATE'.

fieldcatalog-col_pos = 2.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'POSTING_DATE'.

fieldcatalog-seltext_l = 'POSTING DATE'.

fieldcatalog-col_pos = 3.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'TRAN_AMT'.

fieldcatalog-seltext_l = 'TRANSACTION AMOUNT'.

fieldcatalog-col_pos = 4.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'CURR_KEY'.

fieldcatalog-seltext_l = 'CURRENCY KEY'.

fieldcatalog-col_pos = 5.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'DEBIT_CREDIT'.

fieldcatalog-seltext_l = 'DEBIT CREDIT KEY'.

fieldcatalog-col_pos = 6.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'UPLOAD_DATE'.

fieldcatalog-seltext_l = 'UPLOAD DATE'.

fieldcatalog-col_pos = 1.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = 'Z_PCARD_UPLOAD'

i_callback_top_of_page = 'TOP_OF_PAGE1'

it_fieldcat = fieldcatalog[]

i_save = 'A'

tables

t_outtab = ECARD.

endform. " Disp_rpt

*----


  • PAGE HEADERS IN ALV REPORT

*----


form top_of_page1.

wa-typ = 'S'.

describe table itabe lines rows.

rows = sy-tfill.

nlinechar = rows.

concatenate nlinechar text-001 into

wa-info separated by space.

append wa to header.

wa-typ = 'S'.

describe table itabs lines rows.

rows = sy-tfill.

nlinechar = rows.

concatenate nlinechar text-002 into

wa-info separated by space.

append wa to header.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = header.

clear: header, header[].

endform.

regards

Raja Sekhar

Read only

0 Likes
1,587

Raja,

When you are displaying your ALV, you are using table ECARD as your output table. I can't see where you have defined or populated an internal table called ECARD. Do you mean ITABE (records from ITAB which already exist in ZPCARD)?

Cheers,

Pat.

Read only

0 Likes
1,587

Raja,

The problem hereis that when you find out that a record in ITAB already exists in ZPCARD (ie. is is ITABE), youdo not delete the ITAB record.

This means that when you do your "MODIFY ZPCARD FROM TABLE ITAB" command, you are putting the record back in ZPCARD.

Here is a segment of your code that needs changes (I have also put comments in your code to I can keep track of what is happening - the changes you need to do are in <b>bold</b>)

loop at itab.

  • If INTER_AUDIT_CD is empty, raise an error and stop

  • everything

if itab-inter_audit_cd is initial.

*message i001.

stop.

endif.

  • Make all fields Upper Case

CLEaR L_INDEX.

DO.

L_INDEX = L_INDEX + 1.

ASSIGN COMPONENT L_INDEX OF STRUCTURE ITAB TO <fs>.

IF SY-SUBRC NE 0.

EXIT.

ELSE.

TRANSLATE <FS> TO UPPER CASE.

endif.

ENDDO.

  • ITABE contains records that already exist in ZPCARD.

  • If the record also exists in ITAB, delete the record

  • from ZPCARD

read table itabe with key

inter_audit_cd = itab-inter_audit_cd binary search.

if sy-subrc eq 0.

delete from zpcard where inter_audit_cd eq itabe-inter_audit_cd.

<b>

  • ITAB record exists in ITABE, delete it

delete itab.

</b>

else.

itab-mandt = sy-mandt.

modify itab transporting mandt.

endif.

endloop.

  • Now ITAB only contains records that were not in ZPCARD

  • To display the records that are in error, display ITABE,

  • to display the records that were loaded, use ITAB.

Hope this gets you what you are after.

Cheers,

Pat.

PS. Kindly assign Reward Points to the posts you find helpful.

Read only

0 Likes
1,587

Raja,

In your email you said:

"In upload program, can you place a check (for each field) to make sure the uploading data is "clean" (eg. Formats, etc)? SAP has standard check however, it gives ABAP dump. Instead of system dump, I would like the program to display the line item with "unclean" data."

Ok, your DO loop looks ok to me for converting field contents to upper case. But what do you mean by "clean"? Do you mean Validation checks against check tables?

In an earlier post you said that the load file has the following format:

internal_audit_cd

txn_dt

posting_dt

txn_amt

currency_key

debit_credit

upload_dt

If you want to perform a validation check against the relevant Check Tables, then you can only really do it for CURRENCY_KEY (see table TCURC) and DEBIT_CREDIT (H = Credit / S = Debit).

Please clarify what you mean by "clean".

Cheers,

Pat.