Coverage Report - net.sf.sapjcosupport.SapDebuggingUtil
 
Classes in this File Line Coverage Branch Coverage Complexity
SapDebuggingUtil
0% 
0% 
3,167
 
 1  
 package net.sf.sapjcosupport;
 2  
 
 3  
 import com.sap.mw.jco.JCO;
 4  
 
 5  
 /**
 6  
  * @author Niki Driessen
 7  
  * @since May 24, 2006 - 1:51:25 PM
 8  
  */
 9  0
 public class SapDebuggingUtil {
 10  
     public static void printInputParameters(JCO.Function function) {
 11  0
         JCO.FieldIterator iterator = function.getImportParameterList().fields();
 12  0
         prettyPrint(iterator);
 13  0
     }
 14  
 
 15  
     public static void printOutputParameters(JCO.Function function) {
 16  0
         JCO.FieldIterator iterator = function.getExportParameterList().fields();
 17  0
         prettyPrint(iterator);
 18  0
     }
 19  
 
 20  
     public static void printTableParameters(JCO.Function function) {
 21  0
         JCO.FieldIterator iterator = function.getTableParameterList().fields();
 22  0
         prettyPrint(iterator);
 23  0
     }
 24  
 
 25  
     public static void printStructure(JCO.Structure structure) {
 26  0
         JCO.FieldIterator iterator = structure.fields();
 27  0
         while (iterator.hasNextFields()) {
 28  0
             JCO.Field field = iterator.nextField();
 29  0
             if (field.isStructure()) {
 30  0
                 System.out.println(field.getName() + " [STRUCTURE]");
 31  0
                 printStructure(field.getStructure());
 32  
             }
 33  0
             if (field.isTable()) {
 34  0
                 System.out.println(field.getName() + " [TABLE]");
 35  0
                 printTable(field.getTable());
 36  
             } else {
 37  0
                 System.out.println(field.getName() + " [" + field.getTypeAsString() + "] = " + field.getValue());
 38  
             }
 39  
         }
 40  0
     }
 41  
 
 42  
     public static void printTable(JCO.Table table) {
 43  0
         if (table.isEmpty()) {
 44  0
             System.out.println(table.getName() + " [TABLE] Contains no data");
 45  0
             return;
 46  
         }
 47  0
         System.out.println("table.getNumRows() = " + table.getNumRows());
 48  0
         table.firstRow();
 49  
         do {
 50  
             //table.getRow();
 51  0
             System.out.println("--ROW " + table.getRow() + "----------------------");
 52  0
             JCO.FieldIterator iterator = table.fields();
 53  0
             while (iterator.hasNextFields()) {
 54  0
                 JCO.Field field = iterator.nextField();
 55  0
                 if (field.isTable()) {
 56  0
                     System.out.println(field.getName() + " [TABLE]");
 57  0
                     printTable(field.getTable());
 58  
                 }
 59  0
                 if (field.isTable()) {
 60  0
                     System.out.println(field.getName() + " [STRUCTURE]");
 61  0
                     printStructure(field.getStructure());
 62  
                 } else {
 63  0
                     System.out.println(field.getName() + " [" + field.getTypeAsString() + "][" + field.getDescription() + "] = " + field.getValue());
 64  
                 }
 65  
             }
 66  0
         } while (table.nextRow());
 67  0
     }
 68  
 
 69  
     private static void prettyPrint(JCO.FieldIterator iterator) {
 70  0
         while (iterator.hasNextFields()) {
 71  0
             JCO.Field field = iterator.nextField();
 72  0
             if (field.isStructure()) {
 73  0
                 printStructure(field.getStructure());
 74  0
             } else if (field.isTable()) {
 75  0
                 printTable(field.getTable());
 76  
             } else {
 77  0
                 StringBuffer sb = new StringBuffer();
 78  0
                 sb.append(field.getName());
 79  0
                 sb.append(" [");
 80  0
                 sb.append(field.getTypeAsString());
 81  0
                 sb.append("]");
 82  0
                 sb.append("[");
 83  0
                 sb.append(field.getDescription());
 84  0
                 sb.append("] = ");
 85  0
                 if (field.getValue() == null) {
 86  0
                     sb.append("null");
 87  
                 } else {
 88  0
                     sb.append(field.getValue());
 89  
                 }
 90  0
                 System.out.println(sb.toString());
 91  
             }
 92  
         }
 93  0
     }
 94  
 }