Äëÿ çàïóñêà äàííîãî ìàêðîñà íåîáõîäèìî ïåðåéòè â ðåæèì «Ïðîèçâîäñòâî»-«Ïðîèçâîäñòâåííûå ñïåöèôèêàöèè», âûáðàòü ÏÑï è ïåðåéòè íà åå çàêëàäêó «Ñîñòàâ ÏÑï».

 

Ìàêðîñ «Ñîçäàòü ðàñ÷åòíûé äîêóìåíò äëÿ ïîçèöèé, êîòîðûå íå íóæíî èçãîòàâëèâàòü». Ïîçâîëÿåò ñôîðìèðîâàòü ðàñ÷åòíûé äîêóìåíò äëÿ ïîçèöèé ñîñòàâà ÏÑï, êîòîðûå íå íóæíî èçãîòàâëèâàòü.

 

Sub FormMacro_Ntest1(TCSActiveModule)                              
 
'Ñîçäàíèå ðàñ÷åòíîãî äîêóìåíòà èç ÏÑï
'äëÿ ïîçèöèé, êîòîðûå íå íóæíî èçãîòàâëèâàòü
 
Dim CalcDocs      'îáúåêò "Ðàñ÷åòíûå äîêóìåíòû" 
Dim PspSpecs      'îáúåêò "Ïðîèçâîäñòâåííûå ñïåöèôèêàöèè" 
Dim CalcDoc       'ýêçåìïëÿð ðàñ÷åòíîãî äîêóìåíòà
Dim DocNumber 'íîìåð ðàñ÷åòíîãî äîêóìåíòà
Dim DocName     'íàèìåíîâàíèå ðàñ÷åòíîãî äîêóìåíòà
Dim DocDate       'äàòà ðàñ÷åòíîãî äîêóìåíòà
Dim DocRem       'êîììåíòàðèé ê ðàñ÷åòíîìó äîêóìåíòó
Dim DocTypeID  'èäåíòèôèêàòîð ðàñ÷åòíîãî äîêóìåíòà
Dim CehaID        'èäåíòèôèêàòîð ïîäðàçäåëåíèÿ
Dim BM               'òåêóùàÿ ïîçèöèÿ êóðñîðà
Dim pbStr            'ïðîãðåñáàð
Dim I                    'ñëóæåáíàÿ ïåðåìåííàÿ
                                                                   '
 
    If TCSApp.Inventory.CalculateDocumentTypes.RunModuleForSelect("Âûáåðèòå òèï ðàñ÷åòíîãî äîêóìåíòà", False) Then 'Âûáîð òèïà ðàñ÷åòíîãî äîêóìåíòà
        If TCSApp.PlantDepartments.RunModuleForSelect("Âûáåðèòå öåõ/ó÷àñòîê", False) Then ' Âûáîð ïîäðàçäåëåíèÿ, ãäå áóäåò ôîðìèðîâàòüñÿ äîêóìåíò
                                                                   
            Set CalcDocs = TCSApp.Inventory.CalculateDocuments     'îáúåêò "Ðàñ÷åòíûå äîêóìåíòû"
                                                                                                     
            DocNumber = ""                                         'Íîìåð äîêóìåíòà (áóäåò
            DocName="Êîìïëåêòàöèÿ ïî çàêàçó"   'Íàèìåíîâàíèå äîêóìåíòà
             
            DocDate = Date()                                                               'Äàòà ñçäàíèÿ
            DocRem = "Êîììåíòàðèé"                                                         'Êîììåíòàðèé ê äîêóìåíòó
            DocTypeID = TCSApp.Inventory.CalculateDocumentTypes.Properties("ID").AsInteger 'Òèï äîêóìåíòà 
            CehaID = TCSApp.PlantDepartments.Properties("ID").AsInteger                    'Ïîäðàçäåëåíèå
            
            CalcDoc = CalcDocs.AddCalculateDocument(DocNumber,DocName,DocDate,DocRem,DocTypeID,CehaID)'Ñîçäàòü äîêóìåíò
    
            Set CalcDoc = CalcDocs.Properties("CalculateDocumentSpecification").AsIDispatch'Ñïåöèôèêàöèÿ
                    
         pbStr = CSDN_VIS_Library.constProgressBarStr                         'Âçÿòü ñòðîêó ïðîãðåññáàðà
         BM = TCSActiveModule.GetBookmark                          'Çàïîìíèòü ïîëæåíèå êóðñîðà
            TCSActiveModule.First                                  'Âñòàòü íà íà÷àëî ñïåöèôèêàöèè
            Do While Not TCSActiveModule.EOF                       'Ïåðåáèðàåì âûäåëåííûå çàïèñè ñïåöèôèêàöèè
                pbStr = CSDN_VIS_Library.ShowProgressBar(pbStr)        'Äâèãàåì ïðîãðåññáàð
                                    
                  If TCSActiveModule.Properties( "N_ORDTREE_NU" ).Value="T" Then                   'Åñëè ýòó ïîçèöèþ íå íóæíî èçãîòàâëèâàòü
                
                    If CalcDoc.Locate("NMK_ID", TCSActiveModule.Properties("NMK_ID").Value, 0) Then'Åñëè òàêàÿ íîìåíêëàòóðà óæå äîáàëåíà 
                       CalcDoc.Edit                                                                'Áåðåì åå íà ðåäàêòèðîâàíèå è ñêëàäûâàåì êîëè÷åñòâî
                       CalcDoc.Properties("QUANTITY").Value = CalcDoc.Properties("QUANTITY").Value + TCSActiveModule.Properties("N_ORDTREE_QUAN").Value
                    Else                                                                           'Åñëè òàêîé íîìåíêëàòóðû åùå íåò
                       CalcDoc.CreateNew                                                           'Ñîçäàåì íîâóþ çàïèñü
                       CalcDoc.Properties("NMK_ID").Value = TCSActiveModule.Properties("NMK_ID").Value          'ID Íîìåíêëàòóðû
                       CalcDoc.Properties("QUANTITY").Value = TCSActiveModule.Properties("N_ORDTREE_QUAN").Value'Êîëè÷åñòâî
                       CalcDoc.Properties("COEFF").Value = TCSActiveModule.Properties("N_ORDTREE_COEFF").Value  'Êîýôôèöèåíò ïåðåñ÷åòà
                       CalcDoc.Properties("MESUR_ID").Value = TCSActiveModule.Properties("MESUR_ID").Value      'ID Åäèíèöû èçìåðåíèÿ
                    End If
                  End If
                    On Error Resume Next                          ' ñëó÷àå îøèáêè ïîäîëæèòü öèêë
                    CalcDoc.SaveChanges                            'Ñîõðàíèì ðàñ÷åòíûé äîêóìåíò, è åñëè ïðîèçîøëà
                    CalcDoc.CancelChanges                         'îøèáêà, îòìåíèì âñå èçìåíåíèÿ
            TCSActiveModule.Next    
            Loop                                                   'Êîíåö öèêëà ïî âûäåëåííûì çàïèñÿì ñïåöèôèêàöèè
            Call TCSApp.HideProgressMessage              'Âûêëþ÷èòü ïðîãðåññáàð
            Call TCSActiveModule.GotoBookmark(BM)   'Âåðíóòü êóðñîð â èñõîäíîå ïîëîæåíèå
            CalcDocs.EditAction.Execute                            'Äàòü äîêóìåíò äëÿ ðó÷íîãî ðåäàêòèðîâàíèÿ
            Set CalcDocs = Nothing                                 'Îñâîáîäèòü "Ðàñ÷åòíûå äîêóìåíòû"
        End If                                                     '
    End If                                                         '
End Sub                                                            '

 

! Ñì. òàêæå:

18.1 Â ðåæèìå «Ïðîèçâîäñòâåííûå ñïåöèôèêàöèè»