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

How to update one table from another table?

Former Member
0 Likes
4,117

Hi,

Please go through the case I am mentioning below and if possible try to provide with a solution.

I am working on a report to generate cash flow forecast, where in one of the fields is "Payroll", in which its being mentioned as:

In the selection screen: I am entering Project ID, profit Center and Period(in MM/YYYY format).

Selection of all entries in table COSP for selected cost elements above, value type 1, version , all periods and for all selected WBS elements and all objects underneath.

From this, update table COFP with information from COSP with value type 62 and same period.

For updation of various fields the following information is being given.

How should we update COFP?

New entries per OBJNR/PERIO and HKONT are required via using the information from COSP:

COFP-MANDT = SY-MANDT

COFP-KOKRS = if COSP-OBJNR begins with ‘PR’

Check table PRPS with COSP-OBJNR = PRPS-OBJNR and enter PRPS-PKOKR

If COSP-OBJNR begins with ‘NV’

Check table AFVC with COSP-OBJNR = AFVC-OBJNR,

go to Table AFKO with AFVC-AUFPL,

go to table AUFK with AFKO-AUFNR and enter AUFK-KOKRS

If COSP-OBJNR begins with ‘OR’

Check table AUFK with COSP-OBJNR = AUFK-OBJNR

and enter AUFK-KOKRS

COFP-BELNR = Check table NRIV, CLIENT = SY-MANDT, OBJECT = RK_BELEG,

SUBOBJECT = COFP-KOKRS, NRRANGENR = ‘05’,

Add 1 to NRLEVEL and begin with 500000000

Use same BELNR for one update-run

COFP-BUZEI = ‘1’ + and 1 in next entry but same update-run

COFP-TWAER = COSP-TWAER

COFP-ZHLDT = always last day of month in field COFP-PERIO

COFP-GJAHR = COSP-GJAHR

COFP-PERIO = if entry in field WKG001 à PERIO = 001

If entry in field WKG006 à PERIO = 006……

COFP-WRTTP = ‘62’

COFP-VRGNG = ‘FIPL’

COFP-POSIT = Check table SKB1 where SAKNR = COSP-KSTAR and use SKB1-FIPOS

for going to table FMCI-FIPOS and enter FMCI-POSIT

COFP-OBJNR = COSP-OBJNR

COFP-HKONT = COSP-KSTAR

COFP-WKGBTR = WKGXXX

COFP-WKGBTRO = -

COFP-WTGBTR = WTGXXX

COFP-WTGBTRO = -

COFP-WOGBTR = WTGXXX

COFP-WOGBTRO = -

COFP-BUKRS1 = -

COFP-GJAHR1 = -

COFP-BELNR1 = -

COFP-BUZEI1 = -

COFP-BUKRS2 = -

COFP-GJAHR2 = -

COFP-BELNR2 = -

COFP-BUZEI2 = -

COFP-EBELN = -

COFP-EBELP = -

COFP-ZEKKN = -

COFP-ETENRM = -

COFP-STUNR = -

COFP-LIFNR = -

COFP-KUNNR = -

COFP-GSBER = -

COFP-BUKRS = (nearly same as COFP-KOKRS!)

if COSP-OBJNR begins with ‘PR’

Check table PRPS with COSP-OBJNR = PRPS-OBJNR and enter PRPS-PBUKR

If COSP-OBJNR begins with ‘NV’

Check table AFVC with COSP-OBJNR = AFVC-OBJNR,

go to Table AFKO with AFVC-AUFPL,

go to table AUFK with AFKO-AUFNR and enter AUFK-BUKRS

If COSP-OBJNR begins with ‘OR’

Check table AUFK with COSP-OBJNR = AUFK-OBJNR

and enter AUFK-BUKRS

COFP-EINDT = -

COFP-SGTXT = -

COFP-GEBER = -

COFP-KURSF = -

COFP-KUFIX = -

COFP-GBETR = -

COFP-KURSR = -

COFP-KURSFIKRS = -

COFP-KZKRS = -

COFP-UMBKZ = -

COFP-KBLNR = -

COFP-KBLPOS = -

COFP-HI FIVOR = -

COFP-LO FIVOR = -

COFP-HI ACCOUNT = -

COFP-LO ACCOUNT = -

COFP-HI LIFNR = -

COFP-LO LIFNR = -

COFP-HI KUNNR = -

COFP-LO KUNNR = -

COFP-XDELETE = -

COFP-HI XOPVW = -

COFP-LO XOPVW = -

COFP-ZAEHK = -

COFP-CHAINBELNR = -

COFP-MWSKZ = -

COFP-LEDNR = -

COFP-BELTP = ‘1’

COFP-VERSN = ‘0’

COFP-OWAER = COSP-TWAER

COFP-CPUDT = SY-DATUM

COFP-CPUTM = SY-TIME

after doing updation, its again saying Selection of all entries in table COFP with value type 51 to 62, selected year, selected cost elements above and for all selected WBS elements and all objects underneath. Summarisation by period.

Now, can someone help me as how to proceed with the entire thing? An elaborate and illustrative answer would be highly appreciable.

If you require any other information....then get back to me ..asap.

Its bit urgent.

Thanks & Regards,

Ravi

Hi,

Please go through the case I am mentioning below and if possible try to provide with a solution.

I am working on a report to generate cash flow forecast, where in one of the fields is "Payroll", in which its being mentioned as:

In the selection screen: I am entering Project ID, profit Center and Period(in MM/YYYY format).

Selection of all entries in table COSP for selected cost elements above, value type 1, version , all periods and for all selected WBS elements and all objects underneath.

From this, update table COFP with information from COSP with value type 62 and same period.

For updation of various fields the following information is being given.

How should we update COFP?

New entries per OBJNR/PERIO and HKONT are required via using the information from COSP:

COFP-MANDT = SY-MANDT

COFP-KOKRS = if COSP-OBJNR begins with ‘PR’

Check table PRPS with COSP-OBJNR = PRPS-OBJNR and enter PRPS-PKOKR

If COSP-OBJNR begins with ‘NV’

Check table AFVC with COSP-OBJNR = AFVC-OBJNR,

go to Table AFKO with AFVC-AUFPL,

go to table AUFK with AFKO-AUFNR and enter AUFK-KOKRS

If COSP-OBJNR begins with ‘OR’

Check table AUFK with COSP-OBJNR = AUFK-OBJNR

and enter AUFK-KOKRS

COFP-BELNR = Check table NRIV, CLIENT = SY-MANDT, OBJECT = RK_BELEG,

SUBOBJECT = COFP-KOKRS, NRRANGENR = ‘05’,

Add 1 to NRLEVEL and begin with 500000000

Use same BELNR for one update-run

COFP-BUZEI = ‘1’ + and 1 in next entry but same update-run

COFP-TWAER = COSP-TWAER

COFP-ZHLDT = always last day of month in field COFP-PERIO

COFP-GJAHR = COSP-GJAHR

COFP-PERIO = if entry in field WKG001 à PERIO = 001

If entry in field WKG006 à PERIO = 006……

COFP-WRTTP = ‘62’

COFP-VRGNG = ‘FIPL’

COFP-POSIT = Check table SKB1 where SAKNR = COSP-KSTAR and use SKB1-FIPOS

for going to table FMCI-FIPOS and enter FMCI-POSIT

COFP-OBJNR = COSP-OBJNR

COFP-HKONT = COSP-KSTAR

COFP-WKGBTR = WKGXXX

COFP-WKGBTRO = -

COFP-WTGBTR = WTGXXX

COFP-WTGBTRO = -

COFP-WOGBTR = WTGXXX

COFP-WOGBTRO = -

COFP-BUKRS1 = -

COFP-GJAHR1 = -

COFP-BELNR1 = -

COFP-BUZEI1 = -

COFP-BUKRS2 = -

COFP-GJAHR2 = -

COFP-BELNR2 = -

COFP-BUZEI2 = -

COFP-EBELN = -

COFP-EBELP = -

COFP-ZEKKN = -

COFP-ETENRM = -

COFP-STUNR = -

COFP-LIFNR = -

COFP-KUNNR = -

COFP-GSBER = -

COFP-BUKRS = (nearly same as COFP-KOKRS!)

if COSP-OBJNR begins with ‘PR’

Check table PRPS with COSP-OBJNR = PRPS-OBJNR and enter PRPS-PBUKR

If COSP-OBJNR begins with ‘NV’

Check table AFVC with COSP-OBJNR = AFVC-OBJNR,

go to Table AFKO with AFVC-AUFPL,

go to table AUFK with AFKO-AUFNR and enter AUFK-BUKRS

If COSP-OBJNR begins with ‘OR’

Check table AUFK with COSP-OBJNR = AUFK-OBJNR

and enter AUFK-BUKRS

COFP-EINDT = -

COFP-SGTXT = -

COFP-GEBER = -

COFP-KURSF = -

COFP-KUFIX = -

COFP-GBETR = -

COFP-KURSR = -

COFP-KURSFIKRS = -

COFP-KZKRS = -

COFP-UMBKZ = -

COFP-KBLNR = -

COFP-KBLPOS = -

COFP-HI FIVOR = -

COFP-LO FIVOR = -

COFP-HI ACCOUNT = -

COFP-LO ACCOUNT = -

COFP-HI LIFNR = -

COFP-LO LIFNR = -

COFP-HI KUNNR = -

COFP-LO KUNNR = -

COFP-XDELETE = -

COFP-HI XOPVW = -

COFP-LO XOPVW = -

COFP-ZAEHK = -

COFP-CHAINBELNR = -

COFP-MWSKZ = -

COFP-LEDNR = -

COFP-BELTP = ‘1’

COFP-VERSN = ‘0’

COFP-OWAER = COSP-TWAER

COFP-CPUDT = SY-DATUM

COFP-CPUTM = SY-TIME

after doing updation, its again saying Selection of all entries in table COFP with value type 51 to 62, selected year, selected cost elements above and for all selected WBS elements and all objects underneath. Summarisation by period.

Now, can someone help me as how to proceed with the entire thing? An elaborate and illustrative answer would be highly appreciable.

If you require any other information....then get back to me ..asap.

Its bit urgent.

Thanks & Regards,

Ravi

9 REPLIES 9
Read only

hymavathi_oruganti
Active Contributor
0 Likes
2,410

select the entries from COSP into an internal table

and update COFP from the internal table

UPDATE TABLE COFP FROM ITAB

Read only

Former Member
0 Likes
2,410

Let me correct one thing

the selection screen I mentioned in my post, should actually come before the actual description of the entire thing.

that means before I start describing about Payroll.

You can read thatas: selection screen first and after entering the values in them...a report will be generated with so many fields, in which Payroll is one among them for which I have mentioned the description.

Sorry for the incovenience.

Thanks & Regards,

Ravi

Read only

Former Member
0 Likes
2,410

Hi

update <table> from <i_tab>

for different conditions.

loop at i_cosp.

if cosp-mandt eq sy-mandt and cosp-objnr eq 'PR'.

Read table i_PRPS with key i_PRPS-OBJNR = i_COSP-OBJNR.

if sy-subrc eq 0.

update PRPS set PKOKR = ? where objnr = i_prpr-objnr.

endif.

endif.

....

similarly for all the conditions

Regards

Message was edited by: Harikishore Sreenivasulu

Read only

0 Likes
2,410

hi,

Thanks a lot for all the replies. Can someone give me the exact syntax to be put for the following entries mentioned above.

COFP-KOKRS, COFP-BELNR, COFP-BUZEI AND COFP-ZHLDT.

Also, if you could see the selection statements mentioned at the top of my query as well as bottom. can someone provide some insight into that even?

If someone could provide with these, it would be really very helpful at this hour of need.

Thanks & Regards,

Ravi

Read only

0 Likes
2,410

hi,

Can someone help on this...? I have posted this query 2 hours back. Can someone please take it into account and reply?

Thanks & Regards,

Ravi

Read only

0 Likes
2,410

Hi,

Someone, please reply to my query. It's very urgent.

I have to complete this before EOD.

Can someone provide some help...?

Point would be rewarded for a nice answer. Please read my question.

Thanks & Regards,

Ravi

Read only

0 Likes
2,410

<b>Never update SAP tables directly.</b>

Use the corresponding transaction to update these tables.

Read only

Former Member
0 Likes
2,410

To respect integrity of data, it is highly recommended not modify or update directly SAP tables.

There might exist a transaction, BAPI, or function to do so.

Robert

Read only

Former Member
0 Likes
2,410

Hi Ravi,

Instead of updating the Table Directly,try to find out thru which TCODE this table is getting updated and in ur program call up the BDC for that TCODE.

Bcoz there may be a hierarchy of tables which will get updated and u cannot update a single table directly .

If u want to find thru which tcode it is getting updated check itin the hierarchy of table in SE11 u may find tcodes try to find the relevant one

Regards

Usha