cancel
Showing results for 
Search instead for 
Did you mean: 

Plz meke me understand the given code!!!!!!

Former Member
0 Kudos

Dear All,

I am giving you the code below. Please any one can explain me the whole program and the purpose. specially form LOOP section to the end of the program.

I will be very kind if someone will help to make me understood.

Regards,

Abhay.

TABLES:bseg.

DATA: it_bseg LIKE bseg OCCURS 0 WITH HEADER LINE.

DATA: it_zseco LIKE zseco OCCURS 0 WITH HEADER LINE.

*DATA: it_zseco TYPE zseco OCCURS 0 WITH HEADER LINE.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS:s_bukrs FOR bseg-bukrs,

s_gjahr FOR bseg-gjahr,

s_belnr FOR bseg-belnr.

SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION.

PERFORM get_data.

&----


*& Form get_data

&----


FORM get_data .

SELECT *

FROM bseg INTO TABLE it_bseg

WHERE belnr IN s_belnr AND

bukrs IN s_bukrs AND

gjahr IN s_gjahr.

IF sy-subrc = 0.

LOOP AT it_bseg .

MOVE-CORRESPONDING it_bseg TO it_zseco.

it_zseco-bupla_old = it_bseg-bupla.

it_zseco-zdate = sy-datum.

it_zseco-usernam = sy-uname.

it_zseco-ztime = sy-uzeit.

IF it_bseg-bupla NE 'B001'.

it_bseg-bupla = 'B001'.

MODIFY it_bseg.

ENDIF.

it_zseco-bupla_new = 'B001'.

APPEND it_zseco.

CLEAR it_zseco.

ENDLOOP.

MODIFY bseg FROM TABLE it_bseg.

MODIFY zseco FROM TABLE it_zseco.

MESSAGE i000 WITH 'tables BSEG & ZSECO updated successfully'.

ELSE.

MESSAGE i000 WITH 'No data found'.

ENDIF.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Selection screen with fields for company code, fiscal year and document number.

Extract all entries matching this selection criteria from table BSEG (document line items) into an internal table.

Populate an internal table it_zseco with each document extracted and the current user/date/time.

Sets the value of field bupla in BSEG to B001 if it does not currently have this value.

Updates these changes to table BSEG.

Updates the audit into to table ZSECO.

Why it's doing this (in this rather shabby way) I don't know.

Regards,

Nick

Answers (1)

Answers (1)

Former Member
0 Kudos

This is <i>extremely</i> dangerous code. It is updating a field in BSEG without updating the same field in the corresponding tables like BSIS, etc.

You shouldn't execute it in a production system without running it by SAP first.

Rob