*&---------------------------------------------------------------------*
*& Report Z_HOPFC_SWITCH
*&
*&---------------------------------------------------------------------*
*& Version 1.0
*& This is a special correction report if you have originals without workstation application.
*& Please note that this is not an official SAP report.
*&---------------------------------------------------------------------*
REPORT z_hopfc_switch.
DATA: it_switch TYPE TABLE OF tdwswitch.
DATA: wa_switch TYPE tdwswitch.
DATA: it_switch_new TYPE TABLE OF tdwswitch.
DATA: it_switch_del TYPE TABLE OF tdwswitch.
DATA: lf_lines TYPE p.
*Select the entries from table TDWSWITCH
SELECT * FROM tdwswitch INTO CORRESPONDING FIELDS OF TABLE it_switch.
* If sy-subrc is '4' no entry exists and one standard CV entry should be created.
IF sy-subrc = 4.
wa_switch-mandt = sy-mandt.
wa_switch-area = 'CV'.
INSERT tdwswitch FROM wa_switch.
ENDIF.
DESCRIBE TABLE it_switch LINES lf_lines.
IF lf_lines > '1'.
*LOOP at it_switch and remove all entries where AREA is not 'CV'
LOOP AT it_switch INTO wa_switch.
IF wa_switch-area <> 'CV'.
DELETE tdwswitch FROM wa_switch.
* wa_switch-mandt = sy-mandt.
* wa_switch-area = 'CV'.
* INSERT tdwswitch FROM wa_switch.
ENDIF.
ENDLOOP.
*Check table content
SELECT * FROM tdwswitch INTO CORRESPONDING FIELDS OF TABLE it_switch.
DESCRIBE TABLE it_switch LINES lf_lines.
LOOP AT it_switch INTO wa_switch.
IF wa_switch-area = 'CV' AND lf_lines = '1'.
WRITE: 'Table updated successfully'.
ENDIF.
ENDLOOP.
ELSE.
*Only one entry - need to check if this entry has area 'CV'
LOOP AT it_switch INTO wa_switch.
IF wa_switch-area = 'CV'.
WRITE: 'Nothing updated'.
EXIT.
ELSE.
DELETE tdwswitch FROM wa_switch.
wa_switch-mandt = sy-mandt.
wa_switch-area = 'CV'.
INSERT tdwswitch FROM wa_switch.
ENDIF.
ENDLOOP.
ENDIF.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
3 | |
3 | |
3 | |
3 | |
2 | |
2 | |
2 | |
2 | |
2 |