Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

Moderator notice The techniques described in this blog are NOT recommended by SAP and many independent professionals would also not recommend their use. It is far better to use the customisation techniques provided by SAP.


If you use the technique described in this blog, you do so at your own risk and you should read the comments section carefully. "It works" is simply not a good enough reason when you are dealing with customer systems.


Before I start on the topic of ASSIGN statement in ABAP, I would like to take the opportunity to introduce myself here. I am a 10 years experienced SAP professional with 4 years experience as a technical consultant and rest as functional. Though I am more of a functional now, I still do not mind diving deep into ABAP getting my hands dirty in coding when the situation asks for it.

Recently I was working on a problem in which I had to populate the value date for the clearing document which is posted after manually clearing the open items for the customer. The tricky thing was to determine at runtime which are the two selected open items selected by the user to clear.

The solution was obvious – FI substitution for value date.

However, knowing that the solution was easy, implementing it, turned out to be quite tricky.

Obstacle 1: Value date was not present in the list of fields to be substituted in BSEG. How to substitute then?

Solution: After doing sufficient amount of research on the internet and exploring the issue with the seniors I learnt that we can open certain fields from the BSEG table for substitution which are initially not allowed by SAP. Yeah I agree opening certain fields from the table “VWTYGB01” is a modification, but looking the possible options at hand and the dire customer requirement we had limited choices and had to take this path. For more details on this kindly look at the hereby mentioned SAP Notes: 842318, 42615.

Also follow the below mentioned links for more information on this.

http://scn.sap.com/thread/3168871

http://scn.sap.com/thread/1254973

Blog: http://scn.sap.com/community/business-one/add-ons/blog/2013/09/27/adding-of-a-particular-field-in-th...

Anyways I do not want to digress too much from the core topic here.

Obstacle 2: Finding out the two document which are to be cleared manually by the user ?

Solution: With no clear approach in sight we started debugging the standard program “SAPMF05A” for F-32 i.e. “Clear Customer data”. Within 5 min of debugging (I am not exaggerating here) we found out that everything tied to the internal table POSTAB[]. My hunch was to read this table in the substitution to dynamically identify the line items. I created a sample substitution and hooked it in the FI postings. For more details on how to create substitution please refer to the link.

The table data was present in the ABAP memory at the time the code control came to the substitution exit sub routine. Please refer to the ABAP memory stack screen shot shown below.

The sole task remaining was to now to read that data. The magic is was done by sole three statements coming to the rescue.

The general syntax as mentioned in the F1 help is ASSIGN (memory_area). Now the interpretation of the memory area is quite interesting.

Assign (lt_itab[]) to <fs>

This will assign the starting memory address of the internal table to <fs>.

Assign (program_name) to <fs>.

This will assign the starting memory address of the complete program ABAP memory to the field symbol.

Assign (‘(program_name)lt_itab[]’ ) to <fs>.

This will assign the starting address of the internal table lt_itab[] from the program_name to the field symbol. As a side note we have to make sure that the program_name is loaded into the ABAP memory at runtime for one to access.

From the SAP help, we do understand the usage of ASSIGN statement, but this implementation will surely stick to my head for forever after this.

Hope this helps other developers as well.

20 Comments