CHANGE sub-command


Defines special process options and field value definitions for the purpose of replacing all or part of the selected segment.

image2021-7-29_19-20-55.png

OPTION

Identifies the processing behavior. For more information, see Processing-paths.

  • ALWAYS Process for either PATH or NOPATH condition.
  • PATH Process on y if the specified path exists.
  • NOPATH Process only if the specified path does not exist.

SET

Defines the specific segment fields and their values to be changed through the specification of COBOL, PL/I, or DBD field names. Cannot be used to change segment keys or the concatenated key of a logical parent.

For more information and examples of this keyword, see SET Keyword.

For more information, see Variable Length Segments.

Examples

The following CHANGE sub-command statement changes the customer name to Howard Industries, the customer status field in the customer segment to A, and sets the first occurrence of the customer order amount to 125,000.

TYPE   RUN;
PSB    DBNAME=CUSTPDBD;
TITLE  LINE01=’CHANGE CUSTOMER STATUS FOR CUSTOMER NUMBER 10357’;
SELECT SEGMENT=CUSTOMER
         WHERE CUST-NUMBER=10357
  CHANGE SEGMENT=CUSTOMER
           SET=(CUST-NAME=C’HOWARD INDUSTRIES’,
                CUST-STATUS=A,
                CUST-QTR-ORDER-AMOUNT(1)=125000); 

The CHANGE sub-command in the following example changes all customer sales zones 17 in region 10 to 18 if the customer sales representative number 1421 exists for a customer. The SALESREP segment is then changed to reflect the new number of 1539, and sales rep name.

TYPE   RUN;
PSB    PCB=2;
TITLE  LINE01=’CHANGE SALES REPS FOR CUSTOMERS IN REGION 10, ZONE 17’;
SELECT SEGMENT=CUSTOMER MAX=ALL
         WHERE CUST-SALES-REGION=10 AND CUST-SALES-ZONE=17
       SEGMENT=SALESREP MAX=ALL
         WHERE CUST-SALES-REP-NBR=1421
  CHANGE SEGMENT=CUSTOMER
           SET=(CUST-SALES-ZONE=18)
         SEGMENT=SALESREP
           SET=(CUST-SALES-REP-NBR=1539,
                CUST-SALES-REP-LNAME=BENINGTON,
                CUST-SALES-REP-FNAME=ALICE); 

In the following statements, customers in region 10 and zone 18 are changed if they haven’t ordered anything since December 31, 1993.

TYPE   RUN;
PSB    DBNAME=CUSTPDBD;
TITLE  LINE01=’CHANGE CUSTOMER STATUS OF CUSTOMERS IN REGION 10, ZONE
18’;
SELECT SEGMENT=CUSTOMER MAX=ALL
         WHERE CUST-SALES-REGION=10 AND CUST-SALES-ZONE=18
       SEGMENT=CUSTORDR MAX=ALL
         WHERE CUST-ORDR-DATE<19940101
  CHANGE SEGMENT=CUSTOMER OPTION=NOPATH SET=(CUST-STATUS=I);

The following CHANGE sub-command statement changes the customer segment using an input PDS member. The customer number starting in column 10 of the input is used to select the customer and the data starting in column 20 is used to update the sales code.

TYPE   RUN;
PSB    PCB=2;
TITLE  LINE01 =’CHANGE ALL CUSTOMERS USING INPUT MEMBER CHNGDATA’;
SET    INPUT  =CHNGDATA;
SELECT SEGMENT=CUSTOMER MAX=ALL
         WHERE CUST-NUMBER=INPUT(10,6,C)
  CHANGE SEGMENT=CUSTOMER
           SET=(CUST-SALES-CODE=INPUT(20,2,C)); 

The following statements change a customer order segment using an input PDS member. If the customer order segment is not found, the customer order is inserted. The OPTION defaults have been entered to demonstrate how this is done.

TYPE   RUN;
PSB    PCB=2;
TITLE  LINE01=’   CHANGE CUSTOMER ORDER IF IT EXISTS’;
TITLE  LINE02=’INSERT CUSTOMER ORDER IF IT DOES NOT EXIST’;
SET    INPUT=CHNGDATA;
SELECT SEGMENT=CUSTOMER MAX=1
         WHERE CUST-NUMBER=INPUT(10,6,C)
       SEGMENT=CUSTORDR MAX=1
         WHERE CUST-ORDR-NUMBER=INPUT(16,8,C)
  CHANGE SEGMENT=CUSTORDR OPTION=PATH
           SET=(CUST-ORDR-ITEMS=INPUT(24,6,C),
                CUST-ORDR-AMOUNT=INPUT(30,9,C))
  INSERT SEGMENT=CUSTORDR OPTION=NOPATH
           SET=(CUST-ORDR-NUMBER=INPUT(16,8,C),
                CUST-ORDR-ITEMS=INPUT(24,6,C),
                CUST-ORDR-AMOUNT=INPUT(30,9,C)); 

Related topics

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*