Skip to Content

Sharing a little bit with the community… and Following the steps of the Guru Christopher Solomon... and the tip of Tal Tzafriri  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!

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply