This website is not affiliated with, sponsored by, or approved by SAP AG.

Populate Z fields (MARA and MARC) from IDOC.

Interfaces (ALE, IDOC, RFC, EDI etc.)

Moderators: Snowy, thx4allthefish

Populate Z fields (MARA and MARC) from IDOC.

Postby DrSidewalk » Mon Feb 11, 2013 12:32 pm

I need to populate the Z-Fields of MARA and MARC tables when Materials are created via IDocs (Basic type MATMAS03).

My understanding is that I need to carry out the following:

1). Against MATMAS01 I need to create a Z-segment (ZMARAM for example) and add the Z-Fields from MARA and MARC.
2). Identifiy the exist routine and add code to detect this new Z-segment (ZMARAM), collect the values and populate the Z-fields for MARA and MARC.

Have I got that about right in terms of the procedure?.

If anyone knows or has done this before then I would appreciate any code examples and maybe the exit name(s). Given time I'm sure I'll find these.

Dr Sidewalk
Last edited by DrSidewalk on Wed Feb 13, 2013 9:03 am, edited 1 time in total.
DrSidewalk
 
Posts: 180
Joined: Thu May 03, 2012 9:35 am

Re: Populate Z fields (MARA and MARC) from IDOC.

Postby Baz » Mon Feb 11, 2013 1:33 pm

i have been using EXIT_SAPLMV01_002 to populate custom fields in material iDoc.
Baz

AsPiRiNg tUlY iDiOt Image

http://www.catb.org/~esr/faqs/smart-questions.html

Image

check out my Podcasts http://dj-baz.podomatic.com
Baz
 
Posts: 4736
Joined: Fri Nov 08, 2002 5:54 am
Location: He's out there! somewhere!!!!

Re: Populate Z fields (MARA and MARC) from IDOC.

Postby DrSidewalk » Wed Feb 13, 2013 7:12 am

Chers Baz,

Don't suposed you have any example code that you used to update MARA customer fields do you?.

I can see how to determine which segment is being processed, can access the data from idoc_data-sdata, and can collect the data to be posted into the MARA/MARC Z fields, but can't see the method used to actually do this.

Dr Sidewalk
DrSidewalk
 
Posts: 180
Joined: Thu May 03, 2012 9:35 am

Re: Populate Z fields (MARA and MARC) from IDOC.

Postby Gothmog » Wed Feb 13, 2013 7:59 am

As I was saying in the CLFMAS topic:
Can't you use MATMAS_BAPI01 (message MATMAS_BAPI) and fill segments E1BPPAREX/E1BPPAREXX (provided the Z-fields have been added to structures BAPI_TE_MARA/BAPI_TE_MARC)?
68 74 74 70 3a 2f 2f 74 69 6e 79 75 72 6c 2e 63 6f 6d 2f 62 64 6f 37 6d 77 67
Gothmog
 
Posts: 1942
Joined: Wed Sep 12, 2007 4:46 am
Location: Probably not home

Re: Populate Z fields (MARA and MARC) from IDOC.

Postby DrSidewalk » Wed Feb 13, 2013 8:59 am

Here's the thing.

The code that I have recently changed creates Materials. The source file has been modified recently so that characteristic data has been added, so I have now also created CLFMAS01 type IDocs as well. WE20 has both these types as 'Process via a background job'. And indeed that's exactly teh process. The IDocs are created via a batch job and the user then manually (daily) processes the IDocs via custom Zprogram. So, All I'm doing is creating the IDocs, but also need to ensure that when they are processed (probably via RESOUT00 program at a guess) then the Z-fields are populated by the data from ZMARAM segment of the IDoc.

So I don't think the use of BAPI is going to help, unless I was processing the IDoc's myself, which I'm not.

My understanding is that I just need to detect the appropriate segment (ZMARAM) in the exit EXIT_SAPLMV01_002, retrieve the data and then post the data to the appropriate Z-fields of MARA and MARC.

I'm going to take another look at the exit because some of the forums entries mention a 'EU' type structure to filled, but teh last I look there seemed to be no such structure in the exit. But I'll check again, just in case.

If I have the wrong end of the stick then please do let me know. Everyone takes a wrong turn sometime. ;)

Dr Sidewalk.
DrSidewalk
 
Posts: 180
Joined: Thu May 03, 2012 9:35 am

Re: Populate Z fields (MARA and MARC) from IDOC.

Postby DrSidewalk » Wed Feb 13, 2013 9:44 am

Ah, I think the problem is that I've been looking at the wrong exit. I believe the correct exit is EXIT_SAPLMV02_002. This has ALL the material related tables as 'CHANGING' parameters, which exit_saplmv01_002 did not have.

So, it now makes sense. I should be able to place the code necessary to populate the Z-fields now.

Hopefully that should be it. Of course I need to create the new segment (ZMARAM) first though and add all the Z-fields from the MARA and MARC table. And then that should be it.

Dr Sidewalk
DrSidewalk
 
Posts: 180
Joined: Thu May 03, 2012 9:35 am

Re: Populate Z fields (MARA and MARC) from IDOC.

Postby Gothmog » Wed Feb 13, 2013 10:25 am

How does the Z-program select the IDocs? By message type ?
You will have to create a new entry in WE82 to assign you IDoc extension to the mesasge used (MATMAS, I guess).
Why not assign IDoc type MATMAS_BAPI01 to the message type you use, and use it in WE20 with process code BAPP ?

edit: Well, you found a way since my last page refresh.
That works too, even if I prefer my way since it's more flexible and require much less work if new fields are added.
And because it's mine. ;)

edit2: well, I would prefer it if it worked - you need message type MATMAS_BAPI to get the right function with process code BAPP. Damn.
68 74 74 70 3a 2f 2f 74 69 6e 79 75 72 6c 2e 63 6f 6d 2f 62 64 6f 37 6d 77 67
Gothmog
 
Posts: 1942
Joined: Wed Sep 12, 2007 4:46 am
Location: Probably not home

Re: Populate Z fields (MARA and MARC) from IDOC.

Postby DrSidewalk » Thu Feb 14, 2013 6:56 am

Gothmog, Thanks for the above suggestions. I'll consider that method.
You seem well versed with the IDOC process. Do you mid if I ask this question, as I'm currently stuck.

As I might have mentioned, I need to populate some custom fields in Mara and Marc tables via an IDOC. I generate the Idoc but do NOT execute it myself. We have a team that does that and deals with any issues.

In WE31 I have created a new segment (strange that you can't use .append entries/structures). That is then RELEASED, for segment type ZE1MARA, Segm. definition ZE1MARAM000.

I believe I then need to add an Extension to my exitsing obj MATMAS03 (basic type MATMAS) via WE30. But here's the thing. When I enter 'MATMAS03' in WE30 and click on the Extension radion button and hit the Create button I am then given three options:

Create new, Create as copy and create successor. I have no idea which one to use, and assume at this point I should be giving my new created extension name (ZE1MARAM) I believe, but I'm not 100% sure.

So, I am attempting to a add a new custom segment to the existing MATMAS03, is that the correct thing to do?.

I also assume that I do NOT need to use WE82 as I'm not creating/changing the Basic type.

Dr Sidewalk
DrSidewalk
 
Posts: 180
Joined: Thu May 03, 2012 9:35 am

Re: Populate Z fields (MARA and MARC) from IDOC.

Postby Gothmog » Thu Feb 14, 2013 8:01 am

DrSidewalk wrote:I believe I then need to add an Extension to my exitsing obj MATMAS03 (basic type MATMAS) via WE30. But here's the thing. When I enter 'MATMAS03' in WE30 and click on the Extension radion button and hit the Create button I am then given three options:

Create new, Create as copy and create successor. I have no idea which one to use, and assume at this point I should be giving my new created extension name (ZE1MARAM) I believe, but I'm not 100% sure.
Use 'Create new' to create an extension of MATMAS03 (that you can call ZMATMAS03, for example). Then you can insert your segment ZE1MARAM under E1MARAM.

DrSidewalk wrote:So, I am attempting to a add a new custom segment to the existing MATMAS03, is that the correct thing to do?.
Absolutely. Several, even, one for each table, or at least one for basic data, one for plant data,... as needed.

DrSidewalk wrote:I also assume that I do NOT need to use WE82 as I'm not creating/changing the Basic type.
You will need to associate message MATMAS to IDoc basic type MAMAS03 extension ZMATMAS03, in order touse these values in WE20.

You can then use exit EXIT_SAPLMV02_002 to read this user segment and modify the values of MARA/MARC/MARD... accordingly.
Note that your user segment must be after the relataed standard one - ZE1MARAM after E1MARAM, ZE1MARCM after E1MARCM, etc.
68 74 74 70 3a 2f 2f 74 69 6e 79 75 72 6c 2e 63 6f 6d 2f 62 64 6f 37 6d 77 67
Gothmog
 
Posts: 1942
Joined: Wed Sep 12, 2007 4:46 am
Location: Probably not home

Re: Populate Z fields (MARA and MARC) from IDOC.

Postby DrSidewalk » Thu Feb 14, 2013 8:55 am

Thanks for that Info Gothmog.

Just one question though. I have created two segments in WE31, added them to the extension ZMATMAS03 and also added an new entry via WE82.

However, the entries in WE82 are:

MATMAS MATMAS01 30A
MATMAS MATMAS02 30D
MATMAS MATMAS03 40A
MATMAS MATMAS03 ZMATMAS03 40A
MATMAS MATMAS04 46C
MATMAS MATMAS05 470

The record in Bold is the one that I added. Now if I goto We30 and look at the Basic type ZMATMAS03 would you expect to see the new segments?. I can see them if I enter We30 and click on 'Extension' and look at obj ZMATMAS03.

Also, in my main z program, the one that creates the Idoc (via a file using RSEINB00) I set the idoc control record up as:

edi_dc40-Tabname = 'EDI_DC40'.
edi_dc40-direct = '2'. "Inbound
edi_dc40-doctyp = 'MATMAS03'.
edi_dc40-mestype = 'MATMAS'.
edi_dc40-medcod = 'LOG'.
edi_dc40-docrel = sy-saprl

Although my program uses constants. I assume that I just need to use the 'ZMATMAS03' document type instead?.

However, the confusing thing to me is that edi_dc40-docrel = sy-saprl in my program. which equates to '620'. But, there's no release 620 in WE82. So I wonder which entry in we82 is being used.

I also think I may have an issue, because in WE30 if I enter the name ZMATMAS03, click on extension and display I can see my handy work. But, if I just click on Basic type for obj ZMATMAS03 I can see a different description. So it looks as though although it let me create an extension named ZMATMAS03 when there was already an obj called ZMATMAS03. In that case I need to remove my extension, and re-create in a different name, perhaps ZMATMAS instead. I have no done this, updated WE82 with Message type MATMAS, basic type MATMAS03 and extension ZMATMAS, release 620 (But not sure about this release).

When I run the program and look at the resulting IDOC in WE05 I can see the Z segments, but the basic type and message type are correct, but it's not using an Extension. That could account for my IDoc error 60 being shown, complaining about no MAKT segment, which it does actually have. But suspect the Z segment has caused it confusion if it's not expecting it, which it will not if the Extension is not showing.

I checked the IDoc header and it is saying it's release 620, so my WE82 entries are correct, being MATMAS, MATMAS03, ZMATMAS, 620, but as mentioned the Idoc itself is not recognising the extension. About to trawl the net to see if I can find out why.



Dr Sidewalk
DrSidewalk
 
Posts: 180
Joined: Thu May 03, 2012 9:35 am

Re: Populate Z fields (MARA and MARC) from IDOC.

Postby Gothmog » Thu Feb 14, 2013 11:53 am

Your ZMATMAS03 is not a basic type, it's an extension of MATMAS03 - that's why WE30 won't find it if you ask for a basic type.

Your Basic type (EDIDC-IDOCTP) is MATMAS03
Your Extension (EDIDC-CIMTYP) is ZMATMAS03
You need both in your IDoc Control segment (and in WE82 for your message, and in WE20 for your message and your partner).
68 74 74 70 3a 2f 2f 74 69 6e 79 75 72 6c 2e 63 6f 6d 2f 62 64 6f 37 6d 77 67
Gothmog
 
Posts: 1942
Joined: Wed Sep 12, 2007 4:46 am
Location: Probably not home


Return to Interfaces

Who is online

Users browsing this forum: No registered users and 5 guests





loading...


This website is not affiliated with, sponsored by, or approved by SAP AG.