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: Modifying DB Table using a Zreport

Former Member
0 Likes
1,822

Hi Techie's,

Please help me in this issue:

Issue goes like this.

I have to update a Database Table using a Zreport.

Database Table name is STPO which is for BOM Item's.

Scenerio for this issue is very simple as i got from my

functionals....as

In any company Producion People creates and changes the Production BOM's which has the BOM usage no. 1.

Now taking the same BOM and same qty's of this particular

BOM...COSTING People copies it and changes the BOM usage no. as 6. field name of BOM usage is STLAN which is in MAST table....

Now requirement is as this Production BOM is not to be

copied or changed by the costing people...

For a day as many as Production BOM has been changed or created a customized Zreport should run and would

take the data related to the Production BOM's and

do the required processing.

you guys dont worry about the logic which i have put in my Zreport....

complete data is in my internal table..

Now i dont know how to modify the Database table..

even i have tried using..

Modify stpo from TABLE it_final.

If sy.sub..

COMMIT WORK.

else.

Roll back..

But it didnt work...

Then i used ..

Loop at it_final into wa_final.

Modify stpo from TABLE wa_final.

if sy-subrc = 0.

Commit work.

else.

Rollback work.

endif.

Please tell me how to do this work perfectly

so that the data which is in my internal Table get

modified in the DATABASE table..

Kindly look into the matter.

Waiting immpatiently....!!!!

Virendra Soni.

SAP-ABAP Consultant.

Hi Techie's,

Please help me in this issue:

Issue goes like this.

I have to update a Database Table using a Zreport.

Database Table name is STPO which is for BOM Item's.

Scenerio for this issue is very simple as i got from my

functionals....as

In any company Producion People creates and changes the Production BOM's which has the BOM usage no. 1.

Now taking the same BOM and same qty's of this particular

BOM...COSTING People copies it and changes the BOM usage no. as 6. field name of BOM usage is STLAN which is in MAST table....

Now requirement is as this Production BOM is not to be

copied or changed by the costing people...

For a day as many as Production BOM has been changed or created a customized Zreport should run and would

take the data related to the Production BOM's and

do the required processing.

you guys dont worry about the logic which i have put in my Zreport....

complete data is in my internal table..

Now i dont know how to modify the Database table..

even i have tried using..

Modify stpo from TABLE it_final.

If sy.sub..

COMMIT WORK.

else.

Roll back..

But it didnt work...

Then i used ..

Loop at it_final into wa_final.

Modify stpo from TABLE wa_final.

if sy-subrc = 0.

Commit work.

else.

Rollback work.

endif.

Please tell me how to do this work perfectly

so that the data which is in my internal Table get

modified in the DATABASE table..

Kindly look into the matter.

Waiting immpatiently....!!!!

Virendra Soni.

SAP-ABAP Consultant.

14 REPLIES 14
Read only

Former Member
0 Likes
1,756

Hi Virendra,

1. Confirm your table it_final has appropriate field

values.

2. Do not use commit/rollback. Check using:

if sy-subrc<>0.

write 'error'.

endif.

3. Ensure you are not modifying any of the primary key field.

Read only

0 Likes
1,756

it is suggested that never try to modify sap standered table ....u have to use bapi,bdc and lsmw for that...but i think ur problem is primary key.

definatly u are trying to modify some primary key just check it out.

Read only

Former Member
0 Likes
1,756

SO what abt table MAST ? U cannt Update Only one Table ? I think SAP will not accept command like ? If its take ? first u have to find out the implications of this COMMAND ?

U can restrict the user to do the changes by using the Authorization Objects ?

Regards

Prabhu

Read only

anversha_s
Active Contributor
0 Likes
1,756

hi,

code like this.

tables stpo.

data :it_final like stpo occurs 0 with header line.

data : flag_error tyep i.

flag_error = 0.

Loop at it_final.

Modify stpo FROM it_final.

if sy-subrc <> 0. " some values might not be updated

flag_error = 1.

endif.

endloop.

if flag_error - 1.

show error.

endif.

regrds,

anver.

Read only

Former Member
0 Likes
1,756

Thank all for good replies...

But i have done it my own...

for this i first deleted the Costing BOM no's from STPO table and and then inserted data having in my Internal Table.

Program did it successfully...!!

Cheers..!!!

Virendra Soni

Read only

Former Member
0 Likes
1,756

Hi all,

Again a issue has come in this...plz read this as i am trying to explain it in very way..and if dont get plz ask me again, as its getting very very important now..

When i do some Quantity or other changes in any of the existing Component for Production BOM and run the Report..it successfully does it and shows the chanages in the STPO TABLE and also in the Transaction CS03 for the Costing BOM.

But now the scene comes as when i add a new component in

the Production BOM, it's successfully coming in the STPO

table and showing that a new component has been added

as in Production BOM and also in Costing BOM.

But when i open the CS03 and try to see the affact..

not showing in the transaction..which is very important.

plz feel free to ask anything on it...and help me ASAP.

Seeking urgent replies..!!

Virendra Soni.

SAP-ABAP Consultant.

Read only

Former Member
0 Likes
1,756

Please help me guys....!!

Virendra Soni.

Read only

Former Member
0 Likes
1,756

Still no replies..!!

Virendra Soni

Read only

0 Likes
1,756

HI

I guess you can use Direct Input Program: RCSBI020 for

this case.

Documentation of the program:

Text

Change BOMs using Batch Input

Description

This report is used to copy changes to BOMs from an external system to the SAP System. Changes to document structures, equipment BOMs, material BOMs, standard BOMs, and functional location BOMs are supported.

The program reads the sequential file you enter and processes the data contained in it.

The sequential file can be on your own application server, the presentation server, or an external application server. If the file is on an external application server, enter the server name. You can display possible entries to help you select one of the available application servers.

If you want the system to write the data to one or more batch input sessions, which you can process manually later, select the report parameter "Create session".

If you leave the "Create session" parameter with its initial value, all BOMs are changed online. In this case, only the BOMs that were changed incorrectly are collected in batch input sessions. You can process these sessions later.

Note

The input data must contain all items that are to be in the target system on the key date.

The report compares the items in the input file with the items in the taget system BOM on the key date, which you include in the BOM header of the input file. All items that are not included in the input file are deleted.

IF you want to transfer several historical change statuses for one BOM you must process each change status individually:

For each historical change status create an individual Batch-Input-Folder and load it into the SAP System. Only after a folder has been posted in the SAP System can you create the next folder for the next change status.

Requirements

Before you can start this report, you must extract the BOM data to be copied from the source system and write the data to a sequential file. To do this, you must implement a program in the source system that collates the data in the required format and creates the file.

You must define a logical name for the sequential file in the customizing functions. This logical name is the reference to the physical name. You can maintain the logical name when you start the report, by calling online help (F1) on the Logical file name field.

The sequential file containing the BOM data should have the following format:

Record type 0: one session record (structure BGR00) per session

The session header contains general administrative data on the batch input session. All records are assigned to the current session header until the next session header in the sequential file.

Record type 1: one session record (structure BICSK) for each BOM to be changed

The BOM header record contains the transaction code (such as CS02 Change Material BOM) and the header data.

In field BICSK-TCODE in structure BICSK, you define the BOM category and therefore the SAP transaction to be called. You can enter the following values in this field:

CV12 for document structures

IB02 for equipment BOMs

CS02 for material BOMs

CS52 for standard BOMs

IB12 for functional location BOMs

Record type 2: one item record (structure BICSP) per item

All BOM item records are assigned to the current BOM header record until the next BOM header record or session header in the sequential file.

Record type 3: one sub-item record (structure BICSU) per sub-item

All BOM sub-item records are assigned to the current BOM item record until the next BOM item record, BOM header record or session header in the sequential file.

Note

When you create the sequential file, please note the following points:

Fields that are not filled out are transferred with their initial values. Do not use any NODATA character defined in the BGR00-NODATA field.

If you do not want default values for the transaction to be entered in these fields, enter the delete character "!" for transfer. For example, if you want to set the indicator for bulk materials, you need to delete the indicator for relevancy to costing, if this is a default value for the transaction.

If field values are to be deleted, you need to copy the delete symbol "!" to the corresponding field.

Fields that contain a date are to be transferred in external format according to the settings in the user master record. The exception is any date entered in the session header. This is always transferred in internal format YYYYMMDD. YYYY is the year, MM is the month and DD is the day.

If fields for quantities or prices contain decimal values, always use the decimal point defined in the user master record.

Procedure

1. Extract the data to be copied from the source system using the program written for this purpose, writing the data to a sequential file.

2. Start the transfer program in the SAP System.

Enter the logical file name for the physical path name under which the sequential file is stored.

To help you find the path name, you can display possible entries.

Decide which server the sequential file is to be read from. You can choose between your own application server, an external application server, and the presentation server.

If the sequential file is to be read from an external application server, enter the server name. You can display possible entries to help you.

Decide whether all BOMs to be transferred are to be collected in sessions or only those that contain errors.

3. The transfer log tells you which sessions, if any, have been created.

4. Process the sessions in order to transfer the changes to BOMs to the SAP System and to modify any BOMs containing errors.

Output

Once the data program has run, you see a log with the following information:

all the errors that occured during processing

all the BOMs that were copied successfully

all the sessions, if any, that have been created

Kind Regards

Eswar

Read only

0 Likes
1,756

Thanks Eswar,

But here the main issue is that..

How would i change this report as per my requirement..?

Coz in my requirement daily night at 12 P:M system

should run this report automatically as i will schedule

it in background and it will run according to the current date.

So here i dont have any kind of file on Application Server or on Presentation Server, which this program is asking about...!!

Will this report copy the changes from Production BOM to Costing BOM ?

Please tell, This would be a great help.

Warm Regards,

-=Virendra=-

Read only

Former Member
0 Likes
1,756

Hi Virendra,

Can you pls make sure taht the internal table it_final has the same structure as STPO, only then the modify will work correctly.

Regards

Abhishek

Read only

0 Likes
1,756

Abishek,

I solved that thing.

yes its having the same structure and also modifying the

STPO table.

But after this againg a issue came as when we change the

quantity of any component of a particular material.

after saving the changes when i run the report it does everything fine and record the changed in STPO and also reflects for the Costing BOM.

But when i add a component or delete a component in a particular material and run my Zreport it successfully modifies the STPO table, but dont reflect in the CS02 transaction.

Please suggest if you got !!

Virendra

Read only

0 Likes
1,756

Hi Virendra

The BINP Program that i have provided you needs an input file.

Follow these steps within you customized program:

Step1: Extract and determine all BOM's that need to be

changed.

Step2: Download the data to a file on application server

with structures defined in the BINP program. You

can get the strucutres through Data Transfer

Tools.

Step3: Submit BINP program: RCSBI020 with the file that

you have downloaded.(A session will be created for

changing the BOM's)

Step4: Submit the session using RSBDCSUB.

This method will ensure the data integrity and can

help you for tracking of the changes made to the BOM.

Hope the above info gives you some idea on addressing

your problem.

Kind Regards

Eswar

Kind Regards

Eswar

Read only

Former Member
0 Likes
1,756

hai..

i gav small prog it may b useful for u ..

now i cheked it is working with master table mara..

pls chk with ur table

DATA: IT_MARA LIKE MARA OCCURS 100 WITH HEADER LINE .

DATA: IT_MODIFY_DATA LIKE OCCURS 100 WITH HEADER LINE .

PARAMETERS P-MATNR LIKE MARA-MATNR." MAT NO

PARAMETERS P-MTART LIKE MARA-MTART."CHANGIN MAT TYPE (fert or halb or roh)

SELECT MATNR MTART FROM MARA INTO CORRESPONDING FIELDS OF TABLE IT_MARA WHERE MATNR = P_MATNR.

IT_MODIFY_DATA = P_MATNR.

IT_MODIFY_DATA = M_MTART.

APPEND IT_MODIFY_DATA.

LOOP AT IT_MARA.

READ TABLE IT_MODIFY_DATA WITH KEY MATNR = IT_MARA-MATNR.

MOVE-CORRESPONDING IT_MODIFY_DATA TO IT-MARA.

MODIFY IT_MARA.

ENDLOOP.

MODIFY MARA FROM TABLE IT_MARA.

COMMIT WORK.