cancel
Showing results for 
Search instead for 
Did you mean: 

Read package status from VBA

amine_lamkaissi
Active Contributor
0 Kudos

Hi guys,

Is there anyway to read the statuts package of an input form from VBA?

Thanks.

Amine

Accepted Solutions (1)

Accepted Solutions (1)

former_member186338
Active Contributor
0 Kudos

You can read message only from write back badi:

Option Explicit

Public api As New FPMXLClient.EPMAddInAutomation
Public submres() As FPMXLClient_OlapUtilities.SubmitResult 'Array!!!

Public Sub SubmitData()
Dim lngTemp As Long

api.SetSilentMode True

submres = api.SubmitWorkSheet(ThisWorkbook.Worksheets("Sheet1"))
For lngTemp = 0 To UBound(submres)
    MsgBox CStr(submres(lngTemp).ErrorMessage)
Next lngTemp

api.SetSilentMode False
End Sub

Answers (3)

Answers (3)

amine_lamkaissi
Active Contributor
0 Kudos

Thanks Vadim.

amine_lamkaissi
Active Contributor
0 Kudos

Hi Vadim,

Thanks for your answer, how can i read this message error returned by the BADI from VBA?

Let's say the message erros is : refresh failed

Thanks.

Amine

former_member185511
Active Participant
0 Kudos

there is a long way to do it. You can write your package log to DM folder before the BADI finish and later on you can read this DM file from VBA and show to the user.

former_member186338
Active Contributor
0 Kudos

Sorry, but how?

former_member185511
Active Participant

you can populate your log message into an internal table (+ you can retrieve also from CL_UJK_LOGGER class), write as a text format to DM folder to the same model where your BADI is triggered. Later on on the EPM template, you can read that DM folder by using DOWNLOAD method and display the content. Only critical point is "how to distinguish your package log". Here you can send a guid from DM package and read back based on this guid. At the same time it is possible you can trigger many package but you want to read the latest one that you triggered from template.

But EPM API doesn't give you an option to list the content of DM folder. Lets say you have 10 files but you won't be able to get their names via API. In this case we are writing the file list of our DM folder content to another txt file which the name is predefined.
More advanced of this logic i am using to populate an offline EXCEL report and download it from an EPM report.

User selects Contexts and clicks generate report button->BADI creates and offline complicated Excel->Save offline excel to DM folder via ABAP->Update DM folder content list to the predefiend txt file-> Display Content of DM folder in the EPM report via download method->User selects what report to be downloaded->Again trigger Download method for the generated offline excel from DM folder (binary format)->Convert to Excel format-> Save to Desktop->Open it.

I am using this method for complicated report scenarios which cannot be achieved via EPM report or very slow reports. User generates reports, later on select report to download from list in an EPM report and offline report is auto-downloaded.

former_member186338
Active Contributor
0 Kudos

First - user is asking about the status of any DM package.

Sequence of events:

1. User launch some DM package (using VBA) and it's running in background.

2. To perform status request user has to perform save from EPM to some specific member combination. The value saved can be used to identify the particular DM package (some reference table or simply comments to some member combination). "Save" has to be performed in VBA using SubmitWorkSheet method (some hidden sheet with simple input form can be used for this purpose).

3. Write back badi (or validation badi) will be triggered and the code to check status of DM package will run:

UserID - visible in write back badi (select package for the same user ID).

EnvironmentID and ModelID also from write back local variables.

Package name and package group - from some reference table.

Then the code will select the latest line based on TIMESTAMP of table UJD_STATUS (we need field STATUS) where USER_ID, APPSET_ID, APPLICATION_ID, PACKAGE_ID,GROUP_ID are set.

The STATUS will be assigned to error message of write back badi.

4. In VBA the error message will be analyzed as a result of SubmitWorkSheet method.

Repeat 2-4 after some delay using timer.

amine_lamkaissi
Active Contributor
0 Kudos

Thanks Bilen.

former_member186338
Active Contributor
0 Kudos

There is no simple way to read package status from VBA! I have already answered this question and provided solution.

In short:

Create write back badi that will read package status if data is send to some special (dummy) combination of members.

The badi will return error message containing status.

VBA can read error message after data save.