Skip to Content
author's profile photo
Former Member

Urgent

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    author's profile photo
    Former Member
    Sep 23, 2005 at 01:26 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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.

  • author's profile photo
    Former Member
    Sep 22, 2005 at 12:27 PM

    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

    Add comment
    10|10000 characters needed characters exceeded