‎2005 Nov 08 6:22 PM
hi all,
i have created the custom posting program(function module) for a requirement and assigned it with procees code. i have done all the necessary configurations but still it is not triggered what could be the reason.
config.tcodes like ( WE81,WE82,WE57,BD51,WE42)
helpfull answers will be rewarded as soon as possible.
regards,
muraliji.
‎2005 Nov 08 6:45 PM
Hi Muraliji;
Below are the steps that I follow when I create a new function module for inbound processing. You have probably followed them already, but I wanted to elaborate in case someone saw this thread in the future and wanted to know the steps in order.
Do you have an IDoc to process? If so, my suggestion is to make sure all these steps have been followed (you did not mention setting up the partner profile) and then try to process the IDoc in transaction WE19 (IDoc test tool). When you process the inbound IDoc, you function module should appear in the dialog box that pops up.
Here are the steps as I follow them:
Step 1: Create the function module.
Step 2: Execute transaction BD51 to define the ALE attributes of the function module. This will make it possible to assign the function module to the process code when the process code is created in step 4.
Step 3: Execute transaction WE57 to assign the function module to the IDoc type and message type. If this step is not done, or done incorrectly, you will get an error message on the IDoc indicating that the Idoc type is not associated with a message type.
Step 4: Execute transaction WE42 to define the process code. This is the step that assigns the function module to the process code.
Step 5: Create/Modify the partner profile and include the new process code.
Cheers,
John
‎2005 Nov 09 1:40 AM
hi john,
thanks for ur reply.but what i am trying to say is when i process the idoc in WE19 my fnmodule will split the idoc based upon 480 pickable line items .so a single idoc is read and it is converted into multiple idoc's. the idoc which is executed through WE19 will be changed to status 70.
for example an idoc with 960 line items should be split as an single idoc with 480 and one more idoc with 480 line items.so when i split the idoc my fn module splits the idoc but i again get an idoc with 62 status also generated with all the line items. and also i get the spliitted line items in wrong sequence.
here is the code:
SELECT docnum FROM edidc INTO TABLE it_idoc
WHERE status = '64'
AND mestyp = 'ORDERS'
AND idoctp = 'ORDERS05'.
LOOP AT it_idoc INTO wa_idoc.
*Selecting the IDOCDATA of selected IDocs.
SELECT docnum
segnum
segnam
psgnum
sdata
FROM edid4
INTO CORRESPONDING FIELDS OF TABLE it_edidd
WHERE docnum = wa_idoc-docnum.
it_edidd_new1[] = it_edidd[].
it_edidd_new2[] = it_edidd[].
LOOP AT it_edidd INTO edidd.
CASE edidd-segnam.
*material is got from segement 'e1edp19-idtnr'.
WHEN 'E1EDP19'.
MOVE edidd-sdata TO e1edp19.
IF e1edp19-qualf = '001'.
*customer material is provided to get the vendor material no.
SELECT matnr FROM knmt UP TO 1 ROWS
INTO v_material_number
WHERE kdmat = e1edp19-idtnr.
ENDSELECT.
ELSEIF e1edp19-qualf = '002'.
v_material_number = e1edp19-idtnr.
ELSEIF e1edp19-qualf = '003'.
SELECT matnr FROM mean INTO TABLE it_mtab
WHERE ean11 = e1edp19-idtnr.
IF sy-subrc <> 0.
EXIT.
ELSE.
SORT it_mtab ASCENDING BY matnr.
READ TABLE it_mtab into wa_material INDEX 1.
v_material_number = wa_material-matnr.
ENDIF.
ENDIF.
material item count starts.
PERFORM get_material_count USING v_material_number.
IF l_item_count LE 480.
IF l_item_count EQ 2.
IF l_item_count EQ 5.
LOOP AT it_edidd_new1 INTO wa_edidd
WHERE ( psgnum = edidd-psgnum
OR segnum = edidd-psgnum ).
DELETE TABLE it_edidd_new1 FROM wa_edidd.
ENDLOOP.
READ TABLE it_edidd_new1 WITH KEY segnam = 'E1EDP01'
TRANSPORTING NO FIELDS.
LOOP AT it_edidd_new2 INTO wa_edidd
WHERE segnum GT edidd-psgnum.
IF wa_edidd-segnam = 'E1EDP01'.
DELETE TABLE it_edidd_new2 FROM wa_edidd.
DELETE it_edidd_new2 WHERE psgnum = wa_edidd-segnum.
ENDIF.
ENDLOOP.
*creating segmnets and assigning values to them.
PERFORM assign_segment_numbers.
*generating a new idoc.
PERFORM generate_idoc.
CLEAR l_item_count.
it_edidd_new2 = it_edidd_new1.
ELSE.
LOOP AT it_edidd_new1 INTO wa_edidd
WHERE ( psgnum = edidd-psgnum
OR segnum = edidd-psgnum ).
DELETE TABLE it_edidd_new1 FROM wa_edidd.
ENDLOOP.
ENDIF.
ENDCASE.
AT LAST.
IF v_item_count GE 2.
IF v_item_count GE 5.
READ TABLE it_edidd_new2
WITH KEY segnam = 'E1EDP01'
TRANSPORTING NO FIELDS.
IF sy-subrc EQ 0.
PERFORM assign_segment_numbers.
PERFORM generate_idoc.
ENDIF.
ENDIF.
ENDAT.
ENDLOOP.
IF v_item_count GT 480.
IF v_item_count GT 2.
IF v_item_count GT 5.
*Changing the status of the original IDoc as 70
wa_status-status = '70'.
APPEND wa_status TO it_status.
CLEAR wa_status.
*Update the status of idoc in Database.
CALL FUNCTION 'IDOC_STATUS_WRITE_TO_DATABASE'
EXPORTING
idoc_number = wa_idoc-docnum
TABLES
idoc_status = it_status
EXCEPTIONS
idoc_foreign_lock = 1
idoc_not_found = 2
idoc_status_records_empty = 3
idoc_status_invalid = 4
db_error = 5
OTHERS = 6.
ELSE.
change the control record of the original idoc in table EDIDC
UPDATE edidc SET mestyp = 'ORDERS' WHERE docnum = wa_idoc-docnum.
ENDIF.
ENDLOOP.
FORM get_material_count USING p_v_material_number.
*selecting the Item category group from mvke for incoming material.
SELECT mtpos FROM mvke INTO TABLE it_sales_mat
WHERE matnr = p_v_material_number.
IF sy-subrc NE 0.
EXIT.
ENDIF.
*selecting the Default item category for entries of sales data table.
SELECT pstyv FROM t184 INTO TABLE it_sales_item_cat
FOR ALL ENTRIES IN it_sales_mat
WHERE mtpos = it_sales_mat-mtpos
AND auart = 'ZVM1'
AND uepst = ' '.
*checking whether material is Relevant for picking or putaway.
SELECT komrl FROM tvlp INTO v_komrl
FOR ALL ENTRIES IN it_sales_item_cat
WHERE pstyv = it_sales_item_cat-pstyv
AND komrl = 'X'.
ENDSELECT.
*item counter will be incremented.
l_item_count = l_item_count + 1.
v_item_count = v_item_count + 1.
ENDIF.
ENDFORM. " get_material_count
FORM assigning_segment_numbers.
here i have build the segment numbers for an idoc.
assign_segment_numbers
enform
FORM generate_idoc.
CLEAR edidc.
*Building Control records for IDocs to be generated.
SELECT SINGLE * FROM edidc WHERE docnum = wa_idoc-docnum.
edidc-direct = '2'.
edidc-mestyp = 'ORDERS'.
CLEAR edidc-docnum.
IF sy-subrc EQ 0.
wa_status-status = '64'.
CALL FUNCTION 'IDOC_CREATE_ON_DATABASE'
EXPORTING
idoc_status = wa_status
error_occured = ''
TABLES
idoc_data = it_edidd_new2
CHANGING
idoc_control = edidc
EXCEPTIONS
idoc_input_inconsistent = 1
OTHERS = 2.
ENDIF.
ENDFORM.
helpfull answers will surely be rewarded with points....
regards,
muraliji