2007 Jul 05 10:00 AM
Hi,
I have a custom IDoc with 2 same level segments, No mandatory segments are there. I am filling the IDocs in the following way.
I am filling the first segment in a loop after that I am filling the second segment in a nested loop of the first loop. After filling the second segment it is again going to first segment and it is filling and this process is going on until the loop ends.
I am getting the 26 syntax error in the IDoc.
My IDOC is in the following way right now.
1st segment
2nd segment
1st segment
2nd segment
1st segment
2nd segment
Can anybody tell me is this filling of IDoc is wrong or correct.
Thanks,
BSV.
Hi,
I have a custom IDoc with 2 same level segments, No mandatory segments are there. I am filling the IDocs in the following way.
I am filling the first segment in a loop after that I am filling the second segment in a nested loop of the first loop. After filling the second segment it is again going to first segment and it is filling and this process is going on until the loop ends.
I am getting the 26 syntax error in the IDoc.
My IDOC is in the following way right now.
1st segment
2nd segment
1st segment
2nd segment
1st segment
2nd segment
Can anybody tell me is this filling of IDoc is wrong or correct.
Thanks,
BSV.
2007 Jul 05 10:08 AM
Hi
See the Fun module related to any Std IDOC
and see the code for one Segment population. accordingly try to fill.
sample code will be like this...
Loop ...
case Segment.
when segment1.
<fill the fields>
when segment2.
< fill the fields>
endloop.
So in the loop a segment is filled only once...
Reward points for useful Answers
Regards
Anji
2007 Jul 05 10:12 AM
Hi Anji,
My code is custom code.
But I didn't understand your answer. Could you please eloborate the answer.
Thanks,
BSV.
2007 Jul 05 10:11 AM
Hi,
u need to write like this.
here there are two segments Z1SCSK and Z1SCSP.the first segment is header segment and the second one is item.As header segment will have one record moved to workarea ,for item it will be multiple so moved to internal table.
Extract the data from the segments.
LOOP AT idoc_data INTO wa_data "LOOP AT idoc_data
WHERE docnum = idoc_contrl-docnum.
CASE wa_data-segnam. " CASE gwa_data-segnam
WHEN 'Z1SCSK'. "Header data
MOVE wa_data-sdata TO gwa_z1scsk.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = gwa_z1scsk
IMPORTING
output = gv_vbeln.
WHEN 'Z1SCSP'. "Item data
MOVE wa_data-sdata TO gwa_z1scsp.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = gwa_z1scsp-posnr
IMPORTING
output = gv_posnr.
gwa_z1scsp-posnr = gv_posnr.
APPEND gwa_z1scsp TO i_z1scsp.
ENDCASE. " CASE gwa_data-segnam
ENDLOOP. "LOOP AT idoc_data
Regards,
Nagaraj
2007 Jul 05 10:18 AM
Hi Nagaraj,
As I mentioned in my query, those are not parent child segments. Both are non mandatory same level segments. Their max number of repetitions are 99999 for both the segments.
Thanks,
bsv
2007 Jul 13 11:33 AM
Hi,
What is the syntax error that you are getting?
I would suggest that you put segment 2 as a child of segment 1 since it seems that the two are supposed to relate?
It seems that your output is coming out as
segment 1
segment 2
segment 2
segment 2
..
segment 1
segment 2
segment 2
..
segment 1
segment 2
segment 1
segment 2
segment 2
..
etc.?
I think your current IDoc structure expects all segment 1 records to be output in sequence and then all segment 2 records. I.e.,
segment 1
segment 1
segment 1
segment 1
segment 1
segment 1
segment 2
segment 2
segment 2
segment 2
segment 2
segment 2
segment 2
Does this make sense?
Good luck!
Sukhy
2007 Jul 05 10:15 AM
Hi,
just go through these
EXIT_SAPLMV01_002 Enhancements in Material Master: IDoc
EXIT_SAPLMV02_002 Enhancements in Material Master: IDoc
Go through this userdefined program u can understand .
&----
*& Report ZBT_SEL_PROGRAM *
*& *
&----
*& *
*& *
&----
REPORT zbt_sel_program .
TABLES: mara.
*----
Data declaration
*----
*--Material number selection.
SELECT-OPTIONS: s_matnr FOR mara-matnr.
PARAMETERS:
*--Rec.Partner
p_rcvprn TYPE edi_rcvprn,
*--Message type
p_msgtyp TYPE edi_mestyp.
*----
Internal table declaration
*----
DATA:
*--MARA data
it_mara TYPE STANDARD TABLE OF mara WITH HEADER LINE,
*--To fill the segment Z1MARM
it_temp_mara TYPE STANDARD TABLE OF z1marm WITH HEADER LINE,
*--MAKT data
it_makt TYPE STANDARD TABLE OF makt WITH HEADER LINE,
*--To fill the segment E1MAKTM
it_temp_makt TYPE STANDARD TABLE OF e1maktm WITH HEADER LINE.
DATA: st_edidd TYPE STANDARD TABLE OF edidd WITH HEADER LINE,
st_comm_cont TYPE STANDARD TABLE OF edidc WITH HEADER LINE,
st_mast_cont TYPE edidc.
*--Fetch the data from MARA table
SELECT * FROM mara INTO TABLE it_mara WHERE matnr IN s_matnr.
IF sy-subrc = 0.
SORT it_mara.
ENDIF.
*--Fetch the data from MAKT table
IF NOT it_mara[] IS INITIAL.
SELECT * FROM makt INTO TABLE it_makt FOR ALL ENTRIES IN it_mara
WHERE matnr = it_mara-matnr.
IF sy-subrc = 0.
SORT it_makt.
ENDIF.
ENDIF.
*--Fill the iternal tables which is type the same of Segments
LOOP AT it_mara.
MOVE-CORRESPONDING it_mara TO it_temp_mara.
APPEND it_temp_mara.
CLEAR it_temp_mara.
ENDLOOP.
LOOP AT it_makt.
MOVE-CORRESPONDING it_makt TO it_temp_makt.
APPEND it_temp_makt.
CLEAR it_temp_makt.
ENDLOOP.
*--Fill the segments
LOOP AT it_temp_mara.
st_edidd-segnam = 'Z1MARM'.
st_edidd-sdata = it_temp_mara.
APPEND st_edidd.
CLEAR st_edidd.
ENDLOOP.
LOOP AT it_temp_makt.
st_edidd-segnam = 'E1MAKTM'.
st_edidd-sdata = it_temp_makt.
APPEND st_edidd.
CLEAR st_edidd.
ENDLOOP.
*--Fill Master IDOC
st_mast_cont-rcvprt = 'LS'.
st_mast_cont-rcvprn = p_rcvprn.
st_mast_cont-mestyp = p_msgtyp.
st_mast_cont-idoctp = 'ZMATMAS01'.
*--Create the communication IDOC by passsing master IDOC and control
information.
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
EXPORTING
master_idoc_control = st_mast_cont
OBJ_TYPE = ''
CHNUM = ''
TABLES
communication_idoc_control = st_comm_cont
master_idoc_data = st_edidd
EXCEPTIONS
error_in_idoc_control = 1
error_writing_idoc_status = 2
error_in_idoc_data = 3
sending_logical_system_unknown = 4
OTHERS = 5
.
IF sy-subrc = 0.
*--Commit work
COMMIT WORK.
ENDIF.
*--Display IDOC Number.
LOOP AT st_comm_cont.
WRITE: 'IDOC Numbers:',st_comm_cont-docnum.
ENDLOOP.
Regards