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

Updateing Table Records

Former Member
0 Likes
892

Hi All,

I need to update the table records which i'll get from a unix directory, i need to update in batch session everyday. So other than BDC or LSMW is there anyother way to update only table. Last point to add is i'll be having 2 tables Header and Item table which i need to update.

Regards

VEnk@

8 REPLIES 8
Read only

Former Member
0 Likes
861

Hi,

Yes options are available. There may be a BAPI is available to update the header and item records in SAP.

Read only

vinod_vemuru2
Active Contributor
0 Likes
861

Hello,

Is your tables standard or Z??? If standard, definitely there will be T-code/BAPI for that. In case of Z, you have to BDC or direct table update.

Thanks,

Vinod.

Read only

0 Likes
861

Its Z header and item table and how to do direct table update ??

Any Inputs????

REgards

VEnk@

Edited by: Venkat Reddy on Mar 11, 2010 10:54 AM

Read only

0 Likes
861

Hi,

If it is Z, where are u using this table. I hope there must be some Z-tcode exist for updating this table. You can check where used list of these tables. If any Z-tcode available then You can do BDC for that T-code. If not direct table update is the only option.

Direct table update can be done by INSER/MODIFY/UPDATE statements. Check F1 help on these for more details.

Thanks,

Vinod.

Read only

Former Member
0 Likes
861

            report zmjud001 no standard page heading.
            tables: z_mver.
            parameters: test(60) lower case default '/dir/judit.txt'.
            data: begin of unix_intab occurs 100,
            field(53),

      end of unix_intab.
      data: msg(60).
      ***open the unix file
      open dataset test for input in text mode message msg.
      if sy-subrc <> 0.
      write: / msg.
      exit.

endif.
***load the unix file into an internal table
do.
read dataset test into unix_intab.
if sy-subrc ne 0.
exit.
else.
append unix_intab.
endif.
enddo.
close dataset test.
***to process the data. load the database table
loop at unix_intab.
z_mver-mandt = sy-mandt.
z_mver-matnr = unix_intab-field(10).
translate z_mver-matnr to upper case.
z_mver-werks = unix_intab-field+10(4).
translate z_mver-werks to upper case.
z_mver-gjahr = sy-datum(4).
z_mver-perkz = 'M'.
z_mver-mgv01 = unix_intab-field+14(13).
z_mver-mgv02 = unix_intab-field+27(13).
z_mver-mgv03 = unix_intab-field+40(13).
* to check the data on the screen (this is just for checking purpose)
write: / z_mver-mandt, z_mver-matnr, z_mver-werks, z_mver-gjahr,
z_mver-perkz, z_mver-mgv01,
z_mver-mgv02, z_mver-mgv03.
insert z_mver client specified.
*if the data already had been in table z_mver then sy-subrc will not be
*equal with zero. (this can be *interesting for you - (this list is
*not necessary but it maybe useful for you)
if sy-subrc ne 0.
write:/ z_mver-matnr, z_mver-werks.
endif.
endloop.
Read only

Former Member
0 Likes
861

Continue........


NOTES:
1. This solution is recommended only if the database table is NOT a standard SAP database table .
2. In the above mentioned unix file record's size is 53 bytes.
Every record in the unix file as the same size:
10 bytes for material
04 bytes for plant
13 bytes for corrected consumption for January
13 bytes for corrected consumption for February
13 bytes for corrected consumption for March
3. Table Z_MVER

This table was created to store the consumption values for first quarter of the year.

       

Fields
 
Data Element
 
mandt
 
mandt
 
matnr
 
matnr
 
werks
 
werks
 
gjahr
 
gjahr
 
perkz
 
perkz
 
mgv01
 
mgvbr
 
mgv02
 
mgvbr
 
mgv03
 
mgvbr

Read only

Former Member
0 Likes
861

Update ztable


EXEC SQL.
CONNECT TO :'ZTABLE'
ENDEXEC.

IF sy-subrc EQ 0 .

TRY.

EXEC SQL .
DELETE FROM DISTFILEUPLOAD

ENDEXEC .

CATCH cx_sy_native_sql_error INTO exc_ref.
error_text = exc_ref->get_text( ).
MESSAGE error_text TYPE 'I'.

ENDTRY.

LOOP AT itab_cust .
TRY.
*u2013to insert
EXEC SQL.
**u2013then you can UPDATE here the normal SAP SQL commands
UPDATE................

ENDEXEC.

CATCH cx_sy_native_sql_error INTO exc_ref.
error_text = exc_ref->get_text( ).
MESSAGE error_text TYPE 'I'.
ENDTRY.
ENDLOOP .

ENDIF .

Read only

Former Member
0 Likes
861

Answered