Automic Workload Automation

Expand all | Collapse all

Compare between 2 varas.

  • 1.  Compare between 2 varas.

    Posted Feb 13, 2018 06:00 AM
    I need to Compare 2 vara and if i find any duplicates in those 2 varas then i  need to store duplicate value in another vara, can any one please help with this.

    EX:
    Vara 1

    key    name  usn
    0001  abc     9
    0002  xyz     8
    0003  wer     7

    Vara 2

    key    name  usn
    0001  ghj     11
    0002  yui   10
    0003  wer     7

    Vara 3 : should contain only 
    key    name  usn
    0003  wer     7


  • 2.  Compare between 2 varas.

    Posted Feb 13, 2018 06:15 AM
    I am afraid you should go to the doctor and ask him for pills that help increase your memory...

    :-P

    You posted this question a while ago here:
    https://community.automic.com/discussion/11433/duplicates-values-in-vara

    cheers, Wolfgang



  • 3.  Compare between 2 varas.
    Best Answer

    Posted Feb 13, 2018 06:25 AM
    Hi Wolfgage,

    Ya i remember i had posted a while back but that was using single vara and this is using 2 diff vara and that approach did not suited to my requirement so was trying with this way and got some issue so asked in community.

    Please can u guide me with this appoarch.

    regards,
    Vikram    


  • 4.  Compare between 2 varas.

    Posted Feb 13, 2018 07:35 AM
    Just a matter of modifying my first example a bit... :-)

    here you go...
    ! Set source VARA
    :SET &VARA1# = "VARA.COMM_1"
    :SET &VARA2# = "VARA.COMM_2"
    ! Set result VARA
    :SET &RESULT_VARA# = "VARA.DUPL_RESULT"
    !
    ! clear result VARA
    :DELETE_VAR "VARA.DUPL_RESULT"
    !
    ! Looping for every row through VARA
    :SET &HND_1# = PREP_PROCESS_VAR(&VARA1#)
    :PROCESS &HND_1#
    :  SET &KEY_A# = GET_PROCESS_LINE(&HND_1#, 1)
    :  SET &VAL_A1# = GET_PROCESS_LINE(&HND_1#, 2)
    :  SET &VAL_A2# = GET_PROCESS_LINE(&HND_1#, 3)
    :  SET &VAL_A3# = GET_PROCESS_LINE(&HND_1#, 4)
    :  SET &VAL_A4# = GET_PROCESS_LINE(&HND_1#, 5)
    :  SET &VAL_A5# = GET_PROCESS_LINE(&HND_1#, 6)
    !
    ! 2nd loop to compare Values 1...5
    :  SET &HND_2# = PREP_PROCESS_VAR(&VARA2#)
    :  PROCESS &HND_2#
    :    SET &KEY_B# = GET_PROCESS_LINE(&HND_2#, 1)
    :    SET &VAL_B1# = GET_PROCESS_LINE(&HND_2#, 2)
    :    SET &VAL_B2# = GET_PROCESS_LINE(&HND_2#, 3)
    :    SET &VAL_B3# = GET_PROCESS_LINE(&HND_2#, 4)
    :    SET &VAL_B4# = GET_PROCESS_LINE(&HND_2#, 5)
    :    SET &VAL_B5# = GET_PROCESS_LINE(&HND_2#, 6)
    !
    :    IF &KEY_A# = &KEY_B#
    :      IF &VAL_A1# = &VAL_B1#
    :        IF &VAL_A2# = &VAL_B2#
    :          IF &VAL_A3# = &VAL_B3#
    :            IF &VAL_A4# = &VAL_B4#
    :              IF &VAL_A5# = &VAL_B5#
    :                PRINT "Duplicate value found: &KEY_A# -- &VAL_A1# -- &VAL_A2# -- &VAL_A3# -- &VAL_A4# -- &VAL_A5#"
    :                PUT_VAR &RESULT_VARA#, &KEY_B#, &VAL_B1#, &VAL_B2#, &VAL_B3#, &VAL_B4#, &VAL_B5#
    :                PRINT "PUT_VAR &RESULT_VARA#,&KEY_B#,&VAL_B1#,&VAL_B2#,&VAL_B3#,&VAL_B4#,&VAL_B5#"
    :              ENDIF
    :            ENDIF
    :          ENDIF
    :        ENDIF
    :      ENDIF
    :    ENDIF
    !
    :  ENDPROCESS
    :  CLOSE_PROCESS &HND_2#
    !
    :ENDPROCESS
    :CLOSE_PROCESS &HND_1#

    cheers, Wolfgang


  • 5.  Compare between 2 varas.

    Posted Feb 14, 2018 07:28 AM
    Hi Wolfgang,

    Need your guidelines, what changes i need to do if i have a duplicate value only in 2nd column of a vara, how can i capture it and store in a new vara . please can u provide me your inputs on this.

    FOR EX:
    Vara 1
    key    name  usn
    0001  abc     9
    0002  xyz     8
    0003  wer     7

    Vara 2
    key    name  usn
    0001  ghj     11
    0002  yui     10
    0003  sar      20
    0004  wer     30

    Vara 3 : should contain only 
    key    name  usn
    0003   wer     7
    0004   wer      30


  • 6.  Compare between 2 varas.

    Posted Feb 14, 2018 10:05 AM
    In this case just remove all IF structures but
    :        IF &VAL_A2# = &VAL_B2#
    and the corresponding
    :          ENDIF
    structures.
    Then only VAL2 will be compared.

    cheers, Wolfgang


  • 7.  Compare between 2 varas.

    Posted Feb 19, 2018 04:50 AM
    Hi Wolfgang,

    Sorry for chasing u again, bascially Iam a SAP ABAP Consultant and this Automic is pretty new for me so having some doubts.
     When i do the changes what u had told yes it is comparing each and every line in a both the vara and i am getting all the values in a &RESULT_VARA#, 
    Like this:
     IF &VAL_A1# = &VAL_B1#
    :PRINT "Duplicate value found: &KEY_A# -- &VAL_A1# -- &VAL_A2# -- &VAL_A3# -- &VAL_A4# -- &VAL_A5#"
    :PUT_VAR &RESULT_VARA#, &KEY_A#, &VAL_A1#, &VAL_A2#, &VAL_A3#, &VAL_A4#, &VAL_A5#
    :PRINT "PUT_VAR &RESULT_VARA#,&KEY_A#, &VAL_A1#, &VAL_A2#, &VAL_A3#, &VAL_A4#, &VAL_A5#"
    :        ENDIF
    Please find the below screen shots for my result_vara.
    ifsutnzc8e1n.pnghttps://us.v-cdn.net/5019921/uploads/editor/cr/ifsutnzc8e1n.png" width="935">
    but my intention is only to store the values which are duplicates (Means which r repeated more den once) in a vara, iam reading all the values in a vara using a read rows statement. Please find the screen shot of my vara.

    4uaaeytbchcs.pnghttps://us.v-cdn.net/5019921/uploads/editor/hp/4uaaeytbchcs.png" width="978">
    As u can see marked in red lines in value 1 two values are repeated in this case i want to store only these two columns information in my result vara.
    Please can u provide me your comments on these.



  • 8.  Compare between 2 varas.

    Posted Feb 19, 2018 05:31 AM
    NP - just to be sure - out of you post abov you need  "if i have a duplicate value only in 2nd column of a vara"

    So you need ONLY Value 1 (=column2) to be compared - right?

    cheers, Wolfgang


  • 9.  Compare between 2 varas.

    Posted Feb 19, 2018 05:35 AM
    Hi,

    Yes, i need to compare only value 1(=column 2) and if i found any duplicate copy only those columns information to Result_vara.

    Regards,

    Vikram.


  • 10.  Compare between 2 varas.

    Posted Feb 19, 2018 05:45 AM
    It can only become better if you change your business from ABAP programming to Automic Script ;-)

    here you go:

    ! Set source VARA
    :SET &VARA1# = "VARA.COMM_1"
    :SET &VARA2# = "VARA.COMM_2"
    ! Set result VARA
    :SET &RESULT_VARA# = "VARA.DUPL_RESULT"
    !
    ! clear result VARA
    :DELETE_VAR "VARA.DUPL_RESULT"
    !
    ! Looping for every row through VARA
    :SET &HND_1# = PREP_PROCESS_VAR(&VARA1#)
    :PROCESS &HND_1#
    :  SET &KEY_A# = GET_PROCESS_LINE(&HND_1#, 1)
    :  SET &VAL_A1# = GET_PROCESS_LINE(&HND_1#, 2)
    :  SET &VAL_A2# = GET_PROCESS_LINE(&HND_1#, 3)
    :  SET &VAL_A3# = GET_PROCESS_LINE(&HND_1#, 4)
    :  SET &VAL_A4# = GET_PROCESS_LINE(&HND_1#, 5)
    :  SET &VAL_A5# = GET_PROCESS_LINE(&HND_1#, 6)
    !
    ! 2nd loop to compare Values 1...5
    :  SET &HND_2# = PREP_PROCESS_VAR(&VARA2#)
    :  PROCESS &HND_2#
    :    SET &KEY_B# = GET_PROCESS_LINE(&HND_2#, 1)
    :    SET &VAL_B1# = GET_PROCESS_LINE(&HND_2#, 2)
    :    SET &VAL_B2# = GET_PROCESS_LINE(&HND_2#, 3)
    :    SET &VAL_B3# = GET_PROCESS_LINE(&HND_2#, 4)
    :    SET &VAL_B4# = GET_PROCESS_LINE(&HND_2#, 5)
    :    SET &VAL_B5# = GET_PROCESS_LINE(&HND_2#, 6)
    !
    :      IF &VAL_A1# = &VAL_B1#
    :        PRINT "Duplicate value found: &KEY_A# -- &VAL_A1# -- &VAL_A2# -- &VAL_A3# -- &VAL_A4# -- &VAL_A5#"
    :        PUT_VAR &RESULT_VARA#, &KEY_B#, &VAL_B1#, &VAL_B2#, &VAL_B3#, &VAL_B4#, &VAL_B5#
    :        PRINT "PUT_VAR &RESULT_VARA#,&KEY_B#,&VAL_B1#,&VAL_B2#,&VAL_B3#,&VAL_B4#,&VAL_B5#"
    :      ENDIF
    !
    :  ENDPROCESS
    :  CLOSE_PROCESS &HND_2#
    !
    :ENDPROCESS
    :CLOSE_PROCESS &HND_1#

    cheers, Wolfgang