Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
Sharing a little bit with the community... and Following the steps of the Guru christopher.solomon... and the tip of tal.tzafriri-adi  on the blog HCM Processes & Forms: More Fun with Attachments.

Here you have a brief explanation about how to check for mandatory attachments depending on current process data.

  1. Create a normal generic service implementation

    1. Implement the method and all need it coding in all other methods of the service.

    2. Create an Operation in my case Check Attachment

    3. Add the fields from the form to the service implementation by the customise of the "Fields" option and "Field Groups and Operations"




Check here in this blog, if you need information on how to create a Generic service.

The interesting code of the validation will be on the CHECK ATTACHMENT Method :

First Obtain an instance of the current Process:
      LV_PROCESS = CL_HRASR00_PROCESS_EXECUTE=>GET_INSTANCE(
IV_PROCESS = 'ZPROCESSNAME'
).

Then use the method GET ATTACHMENTS
      LV_PROCESS->GET_ATTACHMENTS(
importing
ET_ATTACHMENTS = LT_ATTACHMENT
* EV_IS_OK =
changing
CT_MESSAGE_LIST = LT_MESSAGE " Internet Service Request: Return Table
).

Inside the LT_ATTACHMENT Table, you will have all customised Attachments types of the processes so you can search for a particular Attachment type using the ATTACHMENT_TYPE If  there is some physical file attached you will have the row ATTACHMENT_CONTENT as NOT INITIAL.


LOOP AT LT_ATTACHMENT ASSIGNING <ATTACHMENT_FS>.

IF <ATTACHMENT_FS>-ATTACHMENT_TYPE = 'TYPE_OF_ATTACHMENT' AND <ATTACHMENT_FS>-ATTACHMENT_CONTENT IS NOT INITIAL.

LV_ATTACH_OK = ABAP_TRUE.

ENDIF.

ENDLOOP.

By now you already now if the process has some specific attachment, then you just need to compare with some of the fields added in the Operation by reading the service_datasets table.
read TABLE service_datasets ASSIGNING <option_fs> with key fieldname = C_FLD_YOUR_FIELD

And then, do whatever is necessary for your requeriment.. as send an error message to the user:

 
MESSAGE ID 'MESSAGE_CLASS' TYPE 'E' NUMBER 'XXX' INTO message_dummy.
MOVE-CORRESPONDING sy TO message.
message_handler->add_message( EXPORTING message = message ).

Hope this help somebody else... This is just a way to do it!

And please keep Sharing!
2 Comments
Labels in this area