27 - Modularization Techniques - Subroutines Part6(Pass by Value and Pass by Reference)

Поделиться
HTML-код
  • Опубликовано: 12 дек 2024

Комментарии • 13

  • @ashishpatil101
    @ashishpatil101 19 дней назад

    We never told the system that p_input1 = pv_input1, then how does it understand that ? Is it going by order in which these parameters are written ?

    • @sapabapbyrahulmehta
      @sapabapbyrahulmehta  17 дней назад +1

      Hello Ashish - Yes. It considers the sequence. For this actual parameter in the PERFORM statement this is the corresponding formal parameter in the FORM statement.

  • @dreamer9857
    @dreamer9857 Год назад +1

    Hello sir, call by refernce and call by value topic doubt chasing me till now😅 now get an idea. I have a doubt.
    I tried both by value and by reference, but finally it consider the numbers that we taken in the formal parameters. How it will be.
    As per the topic, call by value is performing opeartion without effecting the actual parameters, but here the output was displayed based on the input we taken in the formal parameters, not in the actual parameters, it means values we taken in the formal parameter section overrides the actual parameter inputs isn't it.

    • @sapabapbyrahulmehta
      @sapabapbyrahulmehta  Год назад

      Very Good Question - Just took the example of APPEND Program. There are different-2 values for Order Number and Payment Mode. We are calling single subroutine multiple times to pass the different-2 values of Order Number and Payment Mode. In this whole process, Ultimately Formal parameters is playing a vital role to use the different-2 values and reduce the code redundancy.

  • @ahmedgomaa177
    @ahmedgomaa177 8 месяцев назад +1

    is there any difference between pass by reference and pass by address?

    • @ahmedgomaa177
      @ahmedgomaa177 8 месяцев назад

      and what if we added value after changing .. what is the impact ?

    • @sapabapbyrahulmehta
      @sapabapbyrahulmehta  8 месяцев назад

      Pass by reference and pass by address both are same.

  • @bhushangayake2840
    @bhushangayake2840 10 месяцев назад

    Hello sir, as output is pass by reference so that's why output of formal and actual parameter is same.. Upto this point I cleared. But what if output is pass by value?
    Will it be the result like
    Formal output 90
    And actual output 30..
    Because when I took the output as pass by value still the value of output for both actual and formal parameter is same..
    Please explain me this.
    Since from yesterday I've been studying this but don't understand

    • @sapabapbyrahulmehta
      @sapabapbyrahulmehta  10 месяцев назад +2

      Hello Bhushan, below is the answer of your question.
      1) PERFORM SUM USING P_INPUT1 P_INPUT2 CHANGING LV_OUTPUT.
      FORM SUM USING PV_INPUT1 PV_INPUT2 CHANGING PV_OUTPUT.
      PV_OUTPUT = PV_INPUT1 + PV_INPUT2.
      ENDFORM.
      Pass by Reference :
      Suppose I am providing input - 10 , 20 . In the Debugging Mode, check the values of PV_OUPUT and LV_OUTPUT together, as soon the value of PV_OUTPUT changes, it immediately reflects in to LV_OUTPUT , as it is pass by reference.
      2) PERFORM SUM USING P_INPUT1 P_INPUT2 CHANGING LV_OUTPUT.
      FORM SUM USING PV_INPUT1 PV_INPUT2 CHANGING VALUE (PV_OUTPUT)
      PV_OUTPUT = PV_INPUT1 + PV_INPUT2.
      ENDFORM.
      Pass by Value for CHANGING
      Suppose I am providing input - 10 , 20 . In the Debugging Mode, check the values of PV_OUPUT and LV_OUTPUT together, as soon the value of PV_OUTPUT changes, it will not reflect in to LV_OUTPUT , as it is pass by value. Once you come out from the FORM and ENDFORM, result will be copied to LV_OUTPUT.
      So in this case because of CHANGING keyword, results passed to LV_OUTPUT.
      For better understanding , do the same thing to USING now.
      Pass by Value for USING
      3) PERFORM SUM USING P_INPUT1 P_INPUT2 CHANGING LV_OUTPUT.
      FORM SUM USING VALUE(PV_INPUT1) USING( PV_INPUT2) CHANGING VALUE (PV_OUTPUT)
      PV_INPUT1 = 40.
      PV_INPUT2 = 50.
      PV_OUTPUT = PV_INPUT1 + PV_INPUT2.
      ENDFORM.
      In the Debugging Mode, Check the values of P_INPUT1 , P_INPUT2 , PV_INPUT1 , PV_INPUT2 - Assigning the new values to PV_INPUT1 and PV_INPUT2 will not impact P_INPUT1 and P_INPUT2 and even when you come out from the subroutine, the value of P_INPUT1 and P_INPUT2 will not change, as they are the part of USING.
      So, CHANGING and USING is itself very important keywords.

    • @bhushangayake2840
      @bhushangayake2840 10 месяцев назад +1

      @@sapabapbyrahulmehta Thanks a lot sir. I know just to say thanks is not sufficient because for each of my doubts you always there to reply me. Not only me you always reply to everyone. Thank you so much sir

  • @chiranjibisahoo7726
    @chiranjibisahoo7726 5 месяцев назад

    hello sir you use the pass by value only in using parameters in subroutine but how to use pass by value in subroutine without parameter?pz sir reply

    • @sapabapbyrahulmehta
      @sapabapbyrahulmehta  5 месяцев назад

      Hello - In without parameters subroutine, there is no significance of pass by value as we are not passing any parameters.

    • @chiranjibisahoo7726
      @chiranjibisahoo7726 5 месяцев назад

      @@sapabapbyrahulmehta tq sir 🙏