‎2021 Jun 23 8:49 PM
Dear All,
I have a requirement of passing the value form custom method inside main program into another custom method inside the method with value(nested custom methods) .I am not supposed to add any import/export/changing parameter to Method interface. No global values available inside innermost method.I came to know that I can use static variable along with classes for the requirement .However I do not know how to achieve it.
Can anybody kindly guide with little bit of code on how to achieve this.
Regards.
‎2021 Jun 23 9:29 PM
This can be done by following steps:

ZCL_TEST_CONTAINER=>MV_VALUE = 'Hello World!'.DATA: lv_string type string.
lv_string = zcl_test_container=>mv_value.Now you can see the value of the lv_string is 'Hello World!'. You have successfully passed the value from one method to other without using importing/exporting or parameters.
Note: The attribute should be static, else it will not work. That's the key.
Cheers!
Gourab
‎2021 Jun 23 9:05 PM
I've not much of an idea of what you're doing. But let me say this:
You do not have a requirement of passing the value.... etc. You have a goal to achieve. You or someone else has suggested that this is a way. If it isn't you, then go back to that person for clarification.
If it is you, then tell us the actual requirement. What are you wanting to do? If it's enhancing a particular standard SAP method, then which one? If it's all custom, then how, exactly, have you designed the class?
‎2021 Jun 23 9:29 PM
This can be done by following steps:

ZCL_TEST_CONTAINER=>MV_VALUE = 'Hello World!'.DATA: lv_string type string.
lv_string = zcl_test_container=>mv_value.Now you can see the value of the lv_string is 'Hello World!'. You have successfully passed the value from one method to other without using importing/exporting or parameters.
Note: The attribute should be static, else it will not work. That's the key.
Cheers!
Gourab
‎2021 Jun 24 7:40 AM
Great Gaurav. Thanks a lot for helping.
This has worked and I was looking for this solution only.
‎2021 Jun 24 8:20 AM
Please use the COMMENT button for comments, questions, adding details, replying to a comment or a proposed solution or to the OP question, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.
‎2021 Jun 24 8:24 AM
Your solution looks like number 3 (not good!):
https://cdn.zsite.net/us1/upload/201712/f_2a1ca764ce384a33d056f8256f6a1ce5.jpg