Skip to Content
Author's profile photo Former Member

HCM Processes & Forms: Mandatory Attachment depending of current Process Data

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!

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Christopher Solomon
      Christopher Solomon

      Very cool! Well done. Thanks for sharing (and the mention haha). Looking forward to more from you!

      Author's profile photo Muhammad Sohail
      Muhammad Sohail

      I have similar requirement and need to display "attachment missing" message on Check/send button for Initiator level.

      I have attached document, but contents field remains blank in every case, weather you attach some document or not. Could you please explain, if I have missed something.

      Thanks.