cancel
Showing results for 
Search instead for 
Did you mean: 

start a second planning sequence only after succes of first sequence

cornelia_lezoch
Active Contributor
0 Kudos


Hi all,

we have created a VBA-button in an AfO mask which should run 2 planning sequences and then do a save plan data in the end.

As usual in planning, we want to run the second sequence only in case the first sequences has run succesful without any errors and the save should only be done if none of the two sequences produce any error.

we use the VBA command

lReturn = Excel.Application.Run("SAPExecutePlanningSequence", sPlanningSequence)

    If lReturn = 0 Then

        Call mSapErrorHandler(oErrors)

    End If

but the return code which we get back from the sequence is always = 1, no matter whether ther is an error or not.

Therefore the follwoing sequence and save are started, which is not correct.

does anyone have an ides on how to run the two seqneunces and get the correct information about the success or error of the first sequence?

thanks

Cornelia

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Corenlia,

Did you find any solution?. I am facing exactly same issue. The SAPexecuteplanningsequnce always returns 1 even when its failed.

Thanks

NC

cornelia_lezoch
Active Contributor
0 Kudos

Hi,

have a look into note 194970.

regards

Cornelia

Former Member
0 Kudos

Hello Cornelia

This note desciption is : Class references in DDIC structures and released at 2000. Are you sure that note number is correct?

Thank you

Former Member
0 Kudos

Hello Sathish,

try this note : 1942970

grettings

Answers (2)

Answers (2)

0 Kudos

Hello,

Good day!

If anyone is still facing the issue with the above issue can use the below code. It works.

Sub Button1_Click()
Dim lResult As Long
Dim lResult1 As Variant

lResult = Application.Run("SAPExecutePlanningFunction", "PF_1")
lResult1 = Application.Run("SAPListOfMessages", "ERROR")
If IsArray(lResult1) Then
If UBound(lResult1) > 0 Then
MsgBox ("Planning Function ended with error")
End If
End If
End Sub

Thanks.

0 Kudos

hi is this code working only for Planning Functions or it could also work with Planning Sequences?

thank you

Former Member
0 Kudos

Cornelia..

I have precisely the same issue. Trying to execute planning sequences in series with a following save.

Both notes referred to in the replies seem to be in error.

  • 194970 as indicated refers to some DDIC type error
  • 1942970 is out of range and posts as "Document Not released

If you have the correct note number,be that would be a big help.

Thanks

avinashd_m
Participant
0 Kudos

Hi,

you can try using Application.Run ("SAPGetProperty","LastError") API to get the status of the planning sequence execution.

Former Member
0 Kudos

I don't think this will work for my needs.

  • Planning seq # 1 has 9+ steps in it and takes time to run.
  • Planning seq # 2 needs the completed data from # 1, but the VBA runs # 2 immediately after kicking off # 1.

Seq 1 is still running when # 2 is trying to do its work.

1 needs to be completed for 2 to start.

Using VBA to wait ?? number of seconds or minutes is not suitable due to varying system performance times [ and data sizes].

You may recall that in the old Bex world the command area for IP sequences utilized step assignments so planning sequences could be ordered and executed in that order with their respective variables and related settings. How might that functionality be replicated in BO Analysis if at all ?

Thanks.