[SAP] Cloud Application Studio의 CSV File Upload
본문 바로가기
IT/SAP C4 HANA

[SAP] Cloud Application Studio의 CSV File Upload

by DHan- 2020. 1. 6.
728x90

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{
   foreach(var Doc in this.RootAttachment.Document)
   {
         var DocContent = Doc.FileContent.BinaryObject.content.ToString();
 
         var Line       = 1;
         var StartLine = 0;
         var EndLine   = -1;
 
         var DocLength = DocContent.Length();
 
         while(DocLength != StartLine)
         {
            EndLine       = DocContent.Find("\n",StartLine);
            var LineStr   = DocContent.Substring(StartLine, EndLine - StartLine - 1);///
            
            var ColPosition   = 1;
            var StartPosition = 0;
            var EndPosition   = -1;
 
            var Validation = true;
            var VisitCheck = true;
 
            if(Line != 1 && Line != 2)
            {
               var CopyNode : elementsof ProductionList;
               CopyNode.Clear();
 
               while(ColPosition < 6 )
               {
                  var ColStr = "";
 
                  if(ColPosition == 5)
                  {
                     ColStr = LineStr.Substring(EndPosition + 1);
                  }
                  else
                  {
                     EndPosition = LineStr.Find(",",StartPosition);
                     ColStr      = LineStr.Substring(StartPosition, EndPosition - StartPosition);
                  }
 
                  if(ColPosition == 1)
                  {
                     CopyNode.Name1= ColStr;
                  }
                  else if(ColPosition == 2)
                  {
                     CopyNode.Name2= ColStr;
                  }
                  else if(ColPosition == 3)
                  {
                     CopyNode.Name3= ColStr;
                  }
                  else if(ColPosition == 4)
                  {
                     CopyNode.Name4= ColStr;
                  }
 
                  ColPosition   = ColPosition + 1;
                  StartPosition = EndPosition + 1;
 
               }
 
            }
                Line      = Line + 1;
                StartLine = EndLine + 1;
         }
  
  }
   
}
 

 

CSV파일을 첨부파일을 통해 업로드시 해당 데이터를 C4C에 저장하기 위한 로직입니다.

용도에 따라 수정하여 사용합니다.

 

728x90

댓글