Skip to Content
0
Former Member
Oct 17, 2011 at 05:42 PM

Different logic w/o using AT-New

31 Views

Hi all,

In the following code i am updating the log version in int_vrson according to recordes found in int_log

The code is runing ok, but i am looking for different logic to perform the same idea with out using AT-New

Sample of data could be retrieved to internal table int_vrson after select statment is done.

nomtk nomit version

1234 10 1

1234 10 2----> should have new version 3 after performing the logic

1234 20 1---->should have new version 2 after performing the logic

1234 30 2---->should have new version 3 after performing the logic

1235 10 1---->should have new version 2 after performing the logic

1235 20 2---->should have new version 3 after performing the logic

data  int_vrson TYPE STANDARD TABLE OF zehs_tkt_log WITH HEADER LINE.
DATA: int_log TYPE STANDARD TABLE OF zehs_tkt_log WITH HEADER LINE.

SELECT *
  FROM zehs_tkt_log
  INTO CORRESPONDING FIELDS OF TABLE int_vrson
  FOR ALL ENTRIES IN int_log
    WHERE nomtk EQ int_log-nomtk AND
          nomit EQ int_log-nomit.

SORT int_vrson BY nomtk nomit version DESCENDING.
  LOOP AT int_log.
    READ TABLE int_vrson WITH KEY nomtk = int_log-nomtk nomit = int_log-nomit.
    IF sy-subrc <> 0.
      int_log-version = 001.
      int_log-idate = sy-datum.
      int_log-itime = sy-uzeit.
      MODIFY int_log.
    ELSE.
      LOOP AT int_vrson WHERE nomtk EQ int_log-nomtk AND
                              nomit EQ int_log-nomit.
        DATA wf_vrs TYPE i.
        wf_vrs = int_vrson-version.
        AT NEW nomit.
          int_vrson-version = wf_vrs .
          IF sy-subrc EQ 0.
            int_log-version = int_vrson-version + 001.
            int_log-idate = sy-datum.
            int_log-itime = sy-uzeit.
            MODIFY int_log.
          ELSE.
            int_log-version = 001.
            int_log-idate = sy-datum.
            int_log-itime = sy-uzeit.
            MODIFY int_log.
          ENDIF.
        ENDAT.
      ENDLOOP.
    ENDIF.
  ENDLOOP.

  MODIFY zehs_tkt_log FROM TABLE int_log.

BR,

Ali