There was a request to change the value for a specific field in all the variants. Instead of going to each variant and changing the value, how can we mass change all variants at the same time? See this Simple Code for you to mass change the Variant Values. Selection Texts: P_NEW - New Value - in our example IN02
S_REPO - Report Name
CODING: *---------------------------------------------------------------------
REPORT z_mass_change_variant_field NO STANDARD PAGE HEADING
*---------------------------------------------------------------------*
DATA: v_repname TYPE varid-report,
DATA: v_repo TYPE raldb_repo,
DATA: i_varid TYPE STANDARD TABLE OF varid,
DATA: i_valtab TYPE STANDARD TABLE OF rsparams,
SELECTION-SCREEN: BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001. SELECT-OPTIONS: s_repo FOR v_repname,
PARAMETERS: p_txt TYPE char50,
SELECTION-SCREEN: END OF BLOCK blk1. *---------------------------------------------------------------------*
START-OF-SELECTION. * --- Get the report variants as per selection criteria SELECT * FROM varid
IF sy-subrc NE 0. *-- Please Put your message here ENDIF. WRITE: /5 REPORT NAME COLOR 2,
SKIP. LOOP AT i_varid INTO wa_varid. v_repo = wa_varid-report.
CLEAR i_valtab. *--- Read the variant contents CALL FUNCTION RS_VARIANT_CONTENTS
IF sy-subrc NE 0.
LOOP AT i_valtab INTO wa_valtab. *--- Here we check if the text in our example BUKRS is part of the program select-options or parameters IF wa_valtab-selname CS
p_txt.
WRITE: /5 v_repo,
wa_valtab-low = p_new. MODIFY i_valtab FROM wa_valtab. ELSEIF wa_valtab-high CS p_old.
WRITE: /5 v_repo,
wa_valtab-high = p_new. MODIFY i_valtab FROM wa_valtab. ENDIF. ENDIF. ENDLOOP. *----- test run option IF p_tst IS INITIAL. CALL FUNCTION RS_CHANGE_CREATED_VARIANT EXPORTING
TABLES
EXCEPTIONS
OTHERS = 10. IF sy-subrc NE 0. * Capture messages as per your requirement here ENDIF. ENDIF. ENDLOOP. *--- End of program
Fast Links:
SAP Books
ABAP Tips
Best regards,
All the site contents are Copyright © www.erpgreat.com
and the content authors. All rights reserved.
|